Java's LinkedHashMap provides the hook necessary to implement a simple LRU cache. Here's some code where we use LHM in as an LRU cache, in service of providing a variation on the memoization concept:
https://gist.github.com/747395 Whether what's there is sufficient for your needs is another story. :-) - Chas On Dec 30, 2010, at 1:35 PM, Miki wrote: > Hello, > > I'm wring a service that polls RSS feeds (using feedme). And I'd like to act > only on the new entries in each feed. > So far I have something like: > > (defn get-new-entries [seen] > (let [seen? (complement seen)] > (filter #(seen? (:id %)) (get-entries)))) > > (defn poll [sleep-time] > (loop [seen #{}] > (let [entries (get-new-entries seen)] > (doall (map process-entry entries)) > (println "================================") > (Thread/sleep sleep-time) > (recur (union seen (set (map :id entries))))))) > > (Full demo code at https://gist.github.com/760094) > > The problem is that "seen" will grow without bounds. > Is there a built in way to have some sort of LRU cache or should I use > external libraries (like plru)? > > Thanks, > -- > Miki > > -- > 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 -- 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