Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
core cache/memoize issue?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
siyu798  
View profile  
 More options Jul 11 2012, 2:57 pm
From: siyu798 <siyu...@gmail.com>
Date: Wed, 11 Jul 2012 11:57:18 -0700 (PDT)
Local: Wed, Jul 11 2012 2:57 pm
Subject: core cache/memoize issue?

Hi,
   I have been exploring to use core.cache and core.memoize in our clojure
app and have found several issues.  Those issues should have been directed
to Fogus but just in case anyone has clues.

core.cache (v0.6.0):
1) it appears the cache is "broken" once two entries with a same key with
different values are cache in a row
user> (-> (clojure.core.cache/lru-cache-factory {} :threshold 2)
          (assoc :a 1)
          (assoc :b 2)
          (assoc :b 3)
          (assoc :a 4))
{:a 4}
- expects {:a 4 :b 3}

(-> (clojure.core.cache/lru-cache-factory {} :threshold 3)
          (assoc :a 1)
          (assoc :b 2)
          (assoc :b 3)
          (assoc :c 4)
          (assoc :d 5)
          (assoc :e 6))
{:e 6, :d 5}      
- expects {:e 6, :d 5, :c 4}

2) I wonder why the miss fn needs eviction case even if the cache has not
reach the threshold limit, this appears to be the cause of the issue 1)
above

(defcache LRUCache [cache lru tick limit]
  ...
  (miss [_ item result]
    (let [tick+ (inc tick)]
      (if-let [ks (keys lru)]
        (let [k (apply min-key lru ks)]
          (LRUCache. (-> cache (dissoc k) (assoc item result))  ;; eviction case
                     (-> lru (dissoc k) (assoc item tick+))
                     tick+
                     limit))
        (LRUCache. (assoc cache item result)  ;; no change case
                   (assoc lru item tick+)
                   tick+
                   limit))))

core.memoize: it does not work with core.cache with version above 0.5.0

Thanks,
siyu


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Michael Fogus  
View profile  
 More options Jul 11 2012, 7:24 pm
From: Michael Fogus <mefo...@gmail.com>
Date: Wed, 11 Jul 2012 19:24:29 -0400
Local: Wed, Jul 11 2012 7:24 pm
Subject: Re: core cache/memoize issue?
Thank you for the report. I have a fix for the LRU/LU caches on my box
and will have it out in the next day or so. The core.memoize changes
will follow soon after.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
siyu798  
View profile  
 More options Jul 13 2012, 10:56 am
From: siyu798 <siyu...@gmail.com>
Date: Fri, 13 Jul 2012 07:56:03 -0700 (PDT)
Local: Fri, Jul 13 2012 10:56 am
Subject: Re: core cache/memoize issue?

Awesome, thx a lot!!


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »