2

I'm looking for a PHP class which would implement delete($prefix) through the means of key versioning for memcached (or other cache).

If I have a key structure like this:

table/5/23 => {data}
table/5/24 => {data}
table/6/5 => {data}

When I want to invalidate part of the cache, such as clear everything for table/ or table/5 the only option seems to be is to use key versioning as described in this answer.

Is there an existing PHP class, library or snippet which implements such functionality transparently?

(note: I've looked into MongoDB but I can't use it in my project)

Community
  • 1
  • 1
romaninsh
  • 10,606
  • 4
  • 50
  • 70
  • possible duplicate of [Regex on memcached key?](http://stackoverflow.com/questions/2497159/regex-on-memcached-key) – Wrikken Jul 27 '11 at 15:25
  • yeah, thanks for pointing this out. added my vote for closing this. – romaninsh Jul 28 '11 at 13:14
  • Yup, I'm sorry therer isn't a better answer, but the fact memcached can't do it is one of the reasons it's fast. – Wrikken Jul 28 '11 at 13:26
  • I have already implemented versioned keys. Works like a charm. I made function to split path into "table" "5" "23" and look up their versions in versions/table, versions/table/5, versions/table/5/23. Each contains a number. When I need to delete table/5 I increment versions/table/5. Actual data key after deletion will look like this: 1:table/2:5/1:23. It's quite fast, one extra multi-get. – romaninsh Jul 28 '11 at 14:19

0 Answers0