Skip to content

Modern, fast and lightweight C++11 LRU in-memory cache implementation

License

Notifications You must be signed in to change notification settings

AllenInstitute/lruc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lruc

Modern, fast and lightweight C++11 LRU in-memory cache implementation.

Build Requirements

  • Compiler with C++11 standart support
  • CMake >= 3.1

Complexity

lruc::lru_cache::insert
lruc::lru_cache::find
lruc::lru_cache::contains
lruc::lru_cache::remove

Amortized constant on average, worst case linear in the size of the cache.

lruc::lru_cache::clear

Linear in the size of the cache, i.e., the number of elements.

lruc::lru_cache::empty
lruc::lru_cache::size
lruc::lru_cache::max_size
lruc::lru_cache::hit_count
lruc::lru_cache::miss_count
lruc::lru_cache::insert_count
lruc::lru_cache::evict_count
lruc::lru_cache::hit_count
lruc::lru_cache::cbegin
lruc::lru_cache::cend
lruc::lru_cache::to_string

Constant.

Usage

using namespace lruc;

lru_cache<size_t, std::string> cache(42);

cache.insert(1, "Trent");
cache.insert(2, "Reznor");

cache.remove(1);

const lru_cache<size_t, std::string>::const_iterator value_iter = cache.find(2);

if (value_iter != cache.cend())
	std::cout << value_iter->second;
else
	std::cout << cache.to_string();

License

Copyright 2017 Aleksandr Dikanchukov
Licensed under the Apache License, Version 2.0

About

Modern, fast and lightweight C++11 LRU in-memory cache implementation

Resources

License

Stars

Watchers

Forks

Packages

No packages published