NitroCache Usage
Extremely fast, scalable, concurrent, pure Java In-memory cache
Status: Beta
Brought to you by:
hviseria
NitroCache implements java.util.Map interface, which makes it extremely easy to use and pluggable.
NitroCache<String,String> _cache = null; // Every call to NitroCache.getInstance will create new cache. Its not singleton _cache = NitroCache.getInstance(5000, CacheEviction.FIFO);
_cache.put("1000","hello world"); System.out.println(_cache.get("1000");
_cache.remove("1000");
Method | Description | |
---|---|---|
clear() | Clears the cache. Internally creates a new cache | |
containsKey(Object) | Returns true if key present | |
containsValue(Object) | Not Supported | |
entrySet() | Return an entrySet based on current entries* | |
get(Object) | Return value if key is present | |
isEmpty() | Return true if Cache size > 0* | |
keySet() | Return set of keys from the cache* | |
put(K, V) | Add key/value to cache | |
putAll(Map<? extends K, ? extends V>) | In a loop add all key/values | |
remove(Object) | Remove the key if present | |
shutdown() | Stop and clear underlying cache | |
size() | Return size of cache* | |
values() | Return all values from cache* |
Mode | Description | Suggested Usage | |
---|---|---|---|
FIFO | Standard First-in-first-out algorithm. put(key,null) will remove the entry and compacts cache. Adding same key/value again moves the entry to end. | Frequent removal and re-entry of key/values | |
FIFO_V2 | Optimized for speed FIFO. put(key,null) removes entry but does not immediately compact cache. Adding same key/value again does not change order of entry in FIFO queue | Less frequent removal/replace of values for keys. High throughput. | |
LRU | Standard Least Recently Used algorithm | If LRU provides more hits |
Throughput results are very deceiving. These does not tells the real story.
Stable latency response time over a long period of time is what you need to measure. This is what you need from a caching product.
I suggest you take a look on these:
http://www.gigaspaces.com/benchmarks
Can any of these products deliver the same latency with such outliers distribution?
See more here:
http://blog.gigaspaces.com/possible-impossibility-the-race-to-zero-latency/
Shay