Least Recently Used C++ template
  • Shell 85.4%
  • C++ 7.5%
  • HTML 5.8%
  • M4 1.2%
  • Makefile 0.1%
Find a file
2020-07-15 17:03:57 -07:00
.github/workflows Create codeql-analysis.yml 2020-07-15 17:03:57 -07:00
docs copy from SVN trunk 2016-08-07 00:35:43 -07:00
src make the other available licenses explicit in the code as well. This closes #1. 2017-05-30 12:53:01 -07:00
acinclude.m4 copy from SVN trunk 2016-08-07 00:35:43 -07:00
AUTHORS copy from SVN trunk 2016-08-07 00:35:43 -07:00
ChangeLog copy from SVN trunk 2016-08-07 00:35:43 -07:00
configure.ac copy from SVN trunk 2016-08-07 00:35:43 -07:00
COPYING copy from SVN trunk 2016-08-07 00:35:43 -07:00
Doxyfile copy from SVN trunk 2016-08-07 00:35:43 -07:00
INSTALL copy from SVN trunk 2016-08-07 00:35:43 -07:00
LICENSE-AGPL3.txt copy from SVN trunk 2016-08-07 00:35:43 -07:00
LICENSE-CCbysa.html copy from SVN trunk 2016-08-07 00:35:43 -07:00
LICENSE.txt copy from SVN trunk 2016-08-07 00:35:43 -07:00
ltmain.sh copy from SVN trunk 2016-08-07 00:35:43 -07:00
Makefile.am copy from SVN trunk 2016-08-07 00:35:43 -07:00
Makefile.cvs copy from SVN trunk 2016-08-07 00:35:43 -07:00
NEWS copy from SVN trunk 2016-08-07 00:35:43 -07:00
packagemap.xml copy from SVN trunk 2016-08-07 00:35:43 -07:00
README copy from SVN trunk 2016-08-07 00:35:43 -07:00

LRU Cache

Fast, thread safe C++ template with Least Recently Used (LRU)
removal semantics. Complete with a comprehensive unit test
suite. Threading features require the BOOST scientific library to be
installed.

Usage:

An LRU cache is a fixed size cache that discards the oldest (least
recently accessed) elements after it fills up.  It's ideally
suited to be used in situations where you need to speed up access to
slower data sources (databases, synthetic structures, etc.). Below is
a simple example of using it to cache strings using integer keys.

Example:

------------------------->8-----------------------------------------------------------
#include "lru_cache.h"
#include <string>
#include <iostream>

int main(void) {
	// Typedef our template for easy of readability and use.
	typedef LRUCache<int,std::string> string_cache_t;
	
	// Instantiate a string cache with at most three elements.
	string_cache_t *cache = new string_cache_t(3);
	
	// Insert data into the cache.
	std::string quote_1 = "Number is the within of all things. -Pythagoras";
	cache->insert( 4, quote_1 );

	// Fetch it out.
	std::cout << cache->fetch( 4 ) << std::endl;	
}
------------------------------------------8<------------------------------------------

See Also:

   http://patrickaudley.com/code/project/lrucache