Welcome! Please see the About page for a little more info on how this works.

+2 votes
ago in core.cache by
edited ago by

Hi,

I notice that in the wrapped namespace of core.cache, there is a has? function that checks the wrapped cache if it has an element or not. It does this by delegating to the underlying cache c/has? function of the wrapped cache.

For reporting purposes, I need to get the current size of the cache (with the caveat of course that the size could be approximate, given the particular nature of a particular cache - but approximation is fine).

Unfortuantely, a size or count function doesn't exist in the wrapped namespace, it only exists on the wrapped cache itself - thus doing:

(count @wrapped-cache)

does return the value.

It would be good, however, if there was also a similar function in the wrapped namespace, something like this (using size as the function name, but could be something else):

(defn size
   [cache-atom]
   (c/count @cache-atom)

The rationale being that having this function exposed in the wrapped namespace keeps the code consistent - i.e., whilst I can continue to do:

(count @wrapped-cache)

It would more preferrable to keep using the wrapped namespace (as I do with other operations, such as evict), i.e., something along the lines of:

(wrapped/size wrapped-cache)

Do you think this suggestion might be something that could be included in the wrapped namespace?

Thank you.

-=david=-

1 Answer

0 votes
ago by

Seems reasonable.

Created https://clojure.atlassian.net/browse/CCACHE-67

I'm happy to help screen a patch if you're so inclined to provide one.

ago by
Hi,

Thank you. Very happy to provide a patch. I'll get one prepped shortly.

-=david=-
ago by
Hi!

I have a patch ready for your first review. I've also signed the CLA, and I'm on Clojure Jira - I think I need the permission to add a comment + patch :-) Thank you.
...