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
47 lines
1.2 KiB
C++
47 lines
1.2 KiB
C++
// 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
|