Skip to content

Proposal for an object cache #11

wants to merge 17 commits into from

6 participants

evert commented Dec 14, 2011

No description provided.

@beberlei beberlei and 1 other commented on an outdated diff Jan 30, 2012
+ * Check if the key exists in the cache.
+ *
+ * @param string $key
+ * @return boolean
+ */
+ function exists($key);
+ /**
+ * Clears the entire cache.
+ *
+ * Implementations may choose to ignore this. What happens in this case
+ * is up to the implementor.
+ *
+ * @return void
+ */
+ function clear();
beberlei added a note Jan 30, 2012

Should not be on the interface imho. Given namespacing of cache keys the behavior even inside the same cache implementation is undefined. We shouldn't give users somethings that can't be trusted. We removed this method from Doctrine cache because of this.

evert added a note Jan 30, 2012
evert added a note Jan 30, 2012

Whoops.. the way the email was formatted it seemed like you were talking about exists() and clear(), but now I see that doesn't make as much sense.

We're been having all disucssions in this group:

Perhaps you feel like joining there and repeating your point?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Any reason the interface is called 'Base' instead of the more expressive 'Cache' ? Same goes for 'Multiple' => MultipleCache.

There's been some discussion around naming on the mailing list.

norv commented May 26, 2012

I really don't think defining an exists() on the cache is a good idea, in particular for a standard and a reference implementation of it. Because mainly of the reasons outlined by yourself as well as others, on making the implementations prone to race conditions.

If anything, the standard and its reference implementation should not promote (or enable too easily) buggy practices, at this level we're talking about here. (one I'm just pulling out of the legacy code...). And anyway, logically speaking, the result returned by exists() is simply not to be relied upon for more than strictly the moment of the call return, which is very error prone.

If exists() information is really needed - needed from the standard cache interface(s) - then probably the best way to provide it is through the discussed CacheEntry class, or CacheItem/CacheRecord as it's called in the alternative implementation.


Hi @evert

If you still support the proposal I've came up with you, php-fig/fig-standards#63 then should this still be opened?

Thank you!

evert commented Mar 12, 2013

Closed this in favor of : #96

@dragoonis dragoonis closed this Apr 22, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.