beryllium / CacheBundle

Symfony2 bundle for memcache and other caching interfaces

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

No obvious way to break the cache

calumbrodie opened this issue · comments

It's important to be able to break the cache by

  1. deleting specific entries by key

and

  1. deleting multiple entries by namespace

I can't find any way to do either. Maybe just missing from the documentation?

Sadly, it's not missing from the documentation, it's just not part of the CacheBundle interface definition at the moment. Several useful pecl-memcache calls are missing (delete, add, replace), along with some lesser-used ones (flush, decrement, increment). Many pecl-memcached calls are also not implemented (append, prepend, cas, fetch, and more).

Memcache doesn't appear to have direct support for clearing multiple entries by namespace or wildcard, so a generic interface like this would probably not be able to support that. The memcached documentation suggests a method of emulating namespaces by hand - unfortunately, it requires the "add" function.

I hope to add support for delete, add, and replace in the near future. You're welcome to fork and try making the change and submitting a PR yourself, if you're interested in accelerating the implementation.

Sorry I was slow to get back to you, and sorry I didn't check the code more closely before asking a stupid question!

Unfortunately I'm not familiar with memcached, but have previously implemented the same feature with APC using APCIterator (http://php.net/manual/en/apciterator.construct.php). This allows you to pass a regex into the constuctor and iterate over cache entries that match the key (deleting them one at a time). Again not ideal, but it is possible. Redis on the other hand though the set data-type (http://redis.io/commands#set) allows this sort of thing easily, and there is a bundle for redis already (https://github.com/snc/SncRedisBundle)

Is there anything in particular that has led you to start your own bundle (not criticizing, I'm just curious) instead of using https://github.com/KnpLabs/KnpZendCacheBundle for example?

edit: and maybe change this issue to a feature request instead

Item #1 has been addressed in the latest commit, but Item #2 is still pending ... I am going to close this issue as multiple deletes are out-of-scope for this bundle at the moment. If people still find it to be worth investigating, I encourage them to open a feature request :)