read


read
or learn more

Announcing: core.memoize v0.5.4

Jun 4, 2013

core.memoize is a Clojure contrib library providing the following features:

  • An underlying PluggableMemoization protocol that allows the use of customizable and swappable memoization caches that adhere to the synchronous CacheProtocol found in core.cache

  • Memoization builders for implementations of common caching strategies, including:

    • First-in-first-out (memo-fifo)
    • Least-recently-used (memo-lru)
    • Least-used (memo-lu)
    • Time-to-live (memo-ttl)
    • Naive cache (memo) that duplicates the functionality of Clojure’s memoize function
  • Functions for manipulating the memoization cache of core.memoize backed functions

Usage

Leiningen dependency information:

[org.clojure/core.memoize "0.5.4"]

Maven dependency information:

<dependency>
  <groupId>org.clojure</groupId>
  <artifactId>core.memoize</artifactId>
  <version>0.5.4</version>
</dependency>

Example Usage

(ns my.cool.lib 
  (:require [clojure.core.memoize :refer (memo-lu)]))
    
(def id (memo-lu #(do (Thread/sleep 5000) v) 3))

(id 42)
; ... waits 5 seconds
;=> 42

(id 42)
; instantly
;=> 42 

Places

Changes from v0.5.3

The v0.5.4 version of core.memoize works with the v0.6.3 version of core.cache. In addition, the following bugs have been fixed:

  • CMEMOIZE-5: Changed to never assume that the value retrieved from the cache is non-nil. This was causing an occassional issue with TTL caches that timed out between checking for a value and retrieving it.
  • CMEMOIZE-2: All references to Unk have been removed.

Plans

The following capabilities are under design, development, or consideration for future versions of core.memoize:

  • LIRS backed memoization
  • SoftCache backed memoization
  • A defn-memo macro
  • A MapMaker style ctor interface
  • test.generative usage
  • More documentation and examples

More planning is needed around capabilities not listed nor thought of.

No Comments, Comment or Ping

Reply to “Announcing: core.memoize v0.5.4”