This project requires JVM version of at least 1.7
lru-cache top
lru-cache
Table of Contents top
A small (~3k) Least Recently Used cache implementation.
Usage top
import synapticloop.datastructures.LruCache;
import synapticloop.datastructures.LruCacheStatistics;
...
// Simply create an LruCache object with the Key and Value Types
// by default - this will have a size of 512 entries
LruCache<Integer, Integer> lruCache = new LruCache<Integer, Integer>();
// you could also create a smaller/larger cache by passing in the cache size
LruCache<Integer, Integer> lruCacheLarge = new LruCache<Integer, Integer>(1024);
LruCache<Integer, Integer> lruCacheSmall = new LruCache<Integer, Integer>(3);
// add some items
lruCacheSmall.put(1, 1);
lruCacheSmall.put(2, 2);
lruCacheSmall.put(3, 3);
// Note that the tail of the cache is the last to be evicted
System.out.println(lruCacheSmall.toString()); // "{ 1:1 }, { 2:2 }, { 3:3 }"
lruCacheSmall.get(2);
System.out.println(lruCacheSmall.toString()); // "{ 1:1 }, { 3:3 }, { 2:2 }"
// now add another entry - to evict one
lruCacheSmall.put(4, 4);
System.out.println(lruCacheSmall.toString()); // "{ 3:3 }, { 2:2 }, { 4:4 }"
Building the Package top
*NIX/Mac OS X top
From the root of the project, simply run
./gradlew build
Windows top
./gradlew.bat build
This will compile and assemble the artefacts into the build/libs/
directory.
Note that this may also run tests (if applicable see the Testing notes)
Running the Tests top
*NIX/Mac OS X top
From the root of the project, simply run
gradle --info test
if you do not have gradle installed, try:
gradlew --info test
Windows top
From the root of the project, simply run
gradle --info test
if you do not have gradle installed, try:
./gradlew.bat --info test
The --info
switch will also output logging for the tests
Dependencies - Gradle top
dependencies {
runtime(group: 'synapticloop', name: 'lru-cache', version: '2.0.1', ext: 'jar')
compile(group: 'synapticloop', name: 'lru-cache', version: '2.0.1', ext: 'jar')
}
or, more simply for versions of gradle greater than 2.1
dependencies {
runtime 'synapticloop:lru-cache:2.0.1'
compile 'synapticloop:lru-cache:2.0.1'
}
Dependencies - Maven top
<dependency>
<groupId>synapticloop</groupId>
<artifactId>lru-cache</artifactId>
<version>2.0.1</version>
<type>jar</type>
</dependency>
Dependencies - Downloads top
You will also need to download the following dependencies:
net.sourceforge.cobertura:cobertura:2.0.3
: (It may be available on one of: bintray mvn central)
junit:junit:4.12
: (It may be available on one of: bintray mvn central)
junit:junit:4.12
: (It may be available on one of: bintray mvn central)
NOTE: You may need to download any dependencies of the above dependencies in turn (i.e. the transitive dependencies)
--
This README.md file was hand-crafted with care utilising synapticloop
templar
->
documentr
--