As already pointed out in #389, method exists()
is the only method in CacheItemInterface
which requires to know which CacheItemPool
the item belongs to.
When trying to figure out, why exists()
exists at all, I stumbled upon this article,
which explains that the reason is memory efficiency for someone who
just needs to peek into the cache to see if the item exists without
caring what it's value is. To avoid race conditions the caller will also
likely not use any other method provided in CacheItemInterface
, unless he calls getItem()
again.
To sum it up, I see no reason why exists()
shouldn't be moved to CacheItemPoolInterface
.
Note: the above text is copypasted from #609.
I don’t care if it exists, but agree that moving it to the pool makes sense. So remove it to move it, I’m okay with either.
We’re not in review anymore, so make a pull request and we can see where this goes.
Rob
To view this discussion on the web visit https://groups.google.com/d/msgid/php-fig/5CD8F955-88CB-4C1F-B307-3C61BCAFC1B5%40tedivm.com.