On Mon, Oct 22, 2012 at 3:30 PM, Hussein B. <hubaghd...@gmail.com> wrote:
> So we need to call evict explicitly if we want to remove an entry? no
> automatic deletion after expiring?

The cache is immutable.

When you call hit / miss, you get a new instance of the cache with the
expired entries removed, and the hit entry updated (if appropriate) or
the miss entry added.

That new instance needs to be stored somewhere (or passed to future
code execution).

Entries will be automatically deleted after expiring in any new
instance of the cache - returned by hit / miss.

You can see that here:

user=> (swap! c3 hit-or-miss :a 1)
{:a 1}
user=> (swap! c3 hit-or-miss :b 2)
{:a 1, :b 2}
user=> (swap! c3 hit-or-miss :c 3)
{:c 3, :b 2}
user=> (swap! c3 hit-or-miss :d 4)
{:c 3, :d 4}
user=> (swap! c3 hit-or-miss :e 5)
{:c 3, :d 4, :e 5}

We add :a, then :b. By the time we add :c, :a has expired (and been
removed). By the time we add :d, :b has expired (and been removed).
Then we add :e before any more expiries. If I wait awhile and add a
new value for :a...

user=> (swap! c3 hit-or-miss :a 6)
{:a 6}

...you'll see :c, :d and :e have expired.
-- 
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/

"Perfection is the enemy of the good."
-- Gustave Flaubert, French realist novelist (1821-1880)

-- 
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

Reply via email to