Announcing core.cache v0.5.0
core.cache is a new Clojure contrib library providing the following features:
An underlying
CacheProtocol
used as the base abstraction for implementing new synchronous cachesA
defcache
macro for hooking yourCacheProtocol
implementations into the Clojure associative data capabilities.Immutable implementations of some basic caching strategies
- First-in-first-out (FIFOCache)
- Least-recently-used (LRUCache)
- Least-used (LUCache)
- Time-to-live (TTLCache)
- Naive cache (BasicCache)
Implementation of an efficient buffer replacement policy based on the low inter-reference recency set algorithm (LIRSCache) described in the LIRS paper
Factory functions for each existing cache type
core.cache is based on a library named Clache, found at http://github.com/fogus/clache that is planned for deprecation.
Absorb
You can use core.cache in your Leiningen and Cake projects with the following :dependencies
directive in your project.clj
file:
[org.clojure/core.cache "0.5.0"]
For Maven-driven projects, use the following slice of XML in your pom.xml
‘s <dependencies>
section:
<dependency>
<groupId>org.clojure</groupId>
<artifactId>core.cache</artifactId>
<version>0.5.0</version>
</dependency>
Enjoy!
Places
- Source code
- Ticket system
- Announcement
- Examples and documentation — in progress
Whither Clache
The v0.5.0 version of core.cache is based almost wholly on the final version of Clache, with the following changes:
An addition of an
evict
function on theCacheProtocol
used to explicitly remove a value from a cache based on a key. All of the existing cache types implement this function except forLIRSCache
.The addition of cache factory functions for all of the existing cache types
The associative structure behaviors are defined solely in terms of the underlying
CacheProtocol
The
SoftCache
implementation was buggy and removed for now
Plans
The following capabilities are under design, development, or consideration for future versions of core.cache:
- Asynchronous caching protocol
LIRSCache evict
- Removal of the
seed
function from theCacheProtocol
- Reimplementation of a cache based on soft references
- test.generative usage
- Deprecation of Clache
- Documentation and examples
More planning is needed around capabilities not listed nor thought of.
:F
3 Comments, Comment or Ping
Ian Phillips
Cool!
One question: how does this relate to Unk? There seems to be quite a bit of overlap between the two projects.
Dec 13th, 2011
fogus
@Ian
core.cache is built from Clache which was the backing store for Unk’s memoization caches. Now core.cache is the backing for core.memoize.
Dec 13th, 2011
Ian Phillips
Ah, that makes sense. I’ve used Unk in a couple of personal POC projects but hadn’t looked into it’s deps so didn’t realise that it was built on top of Clache.
Dec 15th, 2011
Reply to “Announcing core.cache v0.5.0”