Extensible cache templates.
caches is a header only library and is compatible with C++11.
conan search cachesYou can also download the sources.
Documentation and more detailed examples are hosted on Github Pages.
- First in, first out
- Fixed size cache with generic
Telements - Access by value with
T next() constandT last() const
#include <string>
#include <caches/queues/fifo_cache.tpp>
caches::FIFOCache<std::string> cache(2);
cache.push("a");
cache.push("b");
cache.push("c");
cache.size() -> 2UL
cache.next() -> "b"
cache.last() -> "c"- Last in, first out
- Fixed size cache with generic
Telements - Access by value with
T next() constandT last() const
#include <string>
#include <caches/queues/lifo_cache.tpp>
caches::LIFOCache<std::string> cache(2);
cache.push("a");
cache.push("b");
cache.push("c");
cache.size() -> 2UL
cache.next() -> "c"
cache.last() -> "b"- Pops the least recently accessed key
- Fixed size cache of generic
K: Vpairs - Access by value with
operator[](const K &key)
#include <string>
#include <caches/stores/lru_cache.tpp>
caches::LRUCache<std::string, int> cache(2);
cache.store("a", 1);
cache.store("b", 2);
cache.store("c", 3);
cache.size() -> 2UL
cache["b"] -> 2
cache["c"] -> 3- Pops the least recently accessed key
- Fixed size cache of generic
K: Vpairs - Store with move semantics with
void store(const K &key, V &&value) - Access by reference with
V &at(const K &key)
#include <string>
#include <caches/stores/store_cache.tpp>
class Resource {
public:
size_t id;
Resource(const Resource &) = delete;
Resource(Resource &&resource) noexcept : id(resource.id) {}
...
};
caches::StoreCache<std::string, Resource> cache(2);
cache.store("a", Resource(1));
cache.store("b", Resource(2));
cache.store("c", Resource(3));
cache.size() -> 2UL
cache.at("b").id -> 2UL
cache.at("c").id -> 3ULConsider the following scenario:
- You need to generate textures for a game renderer
- You have disabled the copy constructor since they are large objects
- The textures can be given unique names so they can be reused
- Eventually each texture won't be needed when the game scene moves on
The caches::StoreCache lets you store the textures in a map using their ids as keys. They are transferred using move semantics and the least recently used textures are deleted when the container size is reached.
To install dependencies:
yarn install
pip install .[all]
conan install .To run tests:
scons testTo generate the documentation locally:
scons docsTo run linters:
scons lintTo run formatters:
scons formatThe ConanCenter doesn't yet allow users to publish packages independently. Package recipes are submitted to the conan-center-index. A copy of this recipe is kept in this repository in the publish folder. This allows us to test that the recipe is compatible with new versions and makes it easier to submit updates to the conan-center-index.
To test the recipe can build the latest published tag:
conan create publish/all/conanfile.py --version $(yq -r ".versions | keys | .[0]" publish/config.yml)This will fetch the sources and create a locally cached version of the package. This version can also be published to a local remote for testing:
conan upload <package>/<version> -r <remote>Scripts are defined in the scripts folder and can be invoked with toolchains:
To generate header guards:
npx toolchains guardsPlease read this repository's Code of Conduct which outlines our collaboration standards and the Changelog for details on breaking changes that have been made.
This repository adheres to semantic versioning standards. For more information on semantic versioning visit SemVer.
Bump2version is used to version and tag changes. For example:
bump2version patch- Joel Lefkowitz - Initial work
Lots of love to the open source community!






