I see.
But I didn't really grasp the whole concept firmly .
c3 holds a map containing {:a 1} that will lives for two minutes.
After two minutes, requesting :a is generating false since it reached its
TTL but it will still live in map until it is removed explicitly by
invoking evict.
Correct?
Also, would you please explain the recommended pattern to use core.cache
for me?
(if (cache/has? C :c) ;; has? checks that the cache contains an item
(cache/hit C :c) ;; hit returns a cache with any relevant internal
information updated
(cache/miss C :c 42)) ;; miss returns a new cache with the new item and
without evicted entries
What I'm thinking of is a map that will remove an entry automatically
(without calling evict) after TTL.
Thanks a lot!
On Monday, October 22, 2012 11:15:06 PM UTC+3, Sean Corfield wrote:
>
> On Mon, Oct 22, 2012 at 12:05 PM, Michael Fogus
> <[email protected]<javascript:>>
> wrote:
> > First, thanks for trying c.c.cache! The answer to your question is
> > that the TTL cache implementation is non-destructive. The `evict`
> > call returns the cache without the element, but does not remove it
> > from the original cache.
>
> In other words you need something like this:
>
> (def c3 (atom (cache/ttl-cache-factory {:a 1} :ttl 20000)))
> user=> @c3
> {:a 1}
> user=> (cache/has? @c3 :a)
> true
> user=> (cache/has? @c3 :a)
> false
> user=> @c3
> {:a 1}
> user=> (swap! c3 cache/evict :a)
> {}
> user=> @c3
> {}
>
> --
> 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 [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en