Sikuwa first commit
Some checks are pending
CI / Test (Python 3.10 on macos-latest) (push) Waiting to run
CI / Test (Python 3.11 on macos-latest) (push) Waiting to run
CI / Test (Python 3.12 on macos-latest) (push) Waiting to run
CI / Test (Python 3.8 on macos-latest) (push) Waiting to run
CI / Test (Python 3.9 on macos-latest) (push) Waiting to run
CI / Test (Python 3.10 on ubuntu-latest) (push) Waiting to run
CI / Test (Python 3.11 on ubuntu-latest) (push) Waiting to run
CI / Test (Python 3.12 on ubuntu-latest) (push) Waiting to run
CI / Test (Python 3.8 on ubuntu-latest) (push) Waiting to run
CI / Test (Python 3.9 on ubuntu-latest) (push) Waiting to run
CI / Test (Python 3.10 on windows-latest) (push) Waiting to run
CI / Test (Python 3.11 on windows-latest) (push) Waiting to run
CI / Test (Python 3.12 on windows-latest) (push) Waiting to run
CI / Test (Python 3.8 on windows-latest) (push) Waiting to run
CI / Test (Python 3.9 on windows-latest) (push) Waiting to run
CI / Lint (push) Waiting to run
CI / Release (push) Blocked by required conditions
Documentation / Build Documentation (push) Waiting to run
Some checks are pending
CI / Test (Python 3.10 on macos-latest) (push) Waiting to run
CI / Test (Python 3.11 on macos-latest) (push) Waiting to run
CI / Test (Python 3.12 on macos-latest) (push) Waiting to run
CI / Test (Python 3.8 on macos-latest) (push) Waiting to run
CI / Test (Python 3.9 on macos-latest) (push) Waiting to run
CI / Test (Python 3.10 on ubuntu-latest) (push) Waiting to run
CI / Test (Python 3.11 on ubuntu-latest) (push) Waiting to run
CI / Test (Python 3.12 on ubuntu-latest) (push) Waiting to run
CI / Test (Python 3.8 on ubuntu-latest) (push) Waiting to run
CI / Test (Python 3.9 on ubuntu-latest) (push) Waiting to run
CI / Test (Python 3.10 on windows-latest) (push) Waiting to run
CI / Test (Python 3.11 on windows-latest) (push) Waiting to run
CI / Test (Python 3.12 on windows-latest) (push) Waiting to run
CI / Test (Python 3.8 on windows-latest) (push) Waiting to run
CI / Test (Python 3.9 on windows-latest) (push) Waiting to run
CI / Lint (push) Waiting to run
CI / Release (push) Blocked by required conditions
Documentation / Build Documentation (push) Waiting to run
This commit is contained in:
46
cpp_cache/smart_cache_minimal.h
Normal file
46
cpp_cache/smart_cache_minimal.h
Normal file
@@ -0,0 +1,46 @@
|
||||
// sikuwa/cpp_cache/smart_cache_minimal.h
|
||||
// 最小化版本智能缓存系统
|
||||
|
||||
#ifndef SMART_CACHE_MINIMAL_H
|
||||
#define SMART_CACHE_MINIMAL_H
|
||||
|
||||
#include <iostream>
|
||||
#include <unordered_map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <mutex>
|
||||
|
||||
// 简单的LRU缓存实现
|
||||
class LRUCache {
|
||||
private:
|
||||
size_t max_size_;
|
||||
std::unordered_map<std::string, std::string> cache_;
|
||||
std::mutex mutex_;
|
||||
|
||||
public:
|
||||
LRUCache(size_t max_size = 1000);
|
||||
bool put(const std::string& key, const std::string& value);
|
||||
std::string get(const std::string& key);
|
||||
bool contains(const std::string& key);
|
||||
void clear();
|
||||
};
|
||||
|
||||
// 简单的构建缓存系统
|
||||
class BuildCache {
|
||||
private:
|
||||
LRUCache cache_;
|
||||
std::string cache_dir_;
|
||||
std::mutex mutex_;
|
||||
|
||||
public:
|
||||
BuildCache(const std::string& cache_dir = ".cache");
|
||||
bool cache_result(const std::string& target,
|
||||
const std::string& command,
|
||||
const std::string& result);
|
||||
std::string get_result(const std::string& target,
|
||||
const std::string& command);
|
||||
bool needs_rebuild(const std::string& target,
|
||||
const std::string& command);
|
||||
};
|
||||
|
||||
#endif // SMART_CACHE_MINIMAL_H
|
||||
Reference in New Issue
Block a user