cache-dot-clj Clojure library that caches the results of impure functions. It is almost entirely based on the memoize functions described here: http://kotka.de/blog/2010/03/memoize_done_right.html
I have found this useful for caching the results of database calls and for holding HTML snippets. This library is available at clojars.org for use with Leiningen/Maven. Github page: http://github.com/alienscience/cache-dot-clj ==== Example Usage ===== (ns an-example (:use cache-dot-clj.cache)) (defn get-user-from-db "Gets a user details from a database." [username] ;; Slow database read goes here ) ;; Cache the last 1000 users read in ;; i.e support serving a 1000 concurrent users from memory (def get-user-from-db (cached get-user-from-db (lru-cache-strategy 1000))) ;; First read of the user is slow (get-user-from-db "fred") ;; Second is fast (get-user-from-db "fred") ;; When fred's details are changed invalidate the cache (invalidate-cache get-user-from-db "fred") ;; The next call will read from the db and cache the result again (get-user-from-db "fred") -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en