Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to invalidate multiple caches by tags #40

Open
volodymyr-volynets opened this issue Oct 10, 2015 · 1 comment
Open

Ability to invalidate multiple caches by tags #40

volodymyr-volynets opened this issue Oct 10, 2015 · 1 comment

Comments

@volodymyr-volynets
Copy link

Hi,

Here's situation:

  1. One codebase connects to multiple databases;
  2. Few cashes can store data from the same table, data is gathered by different sql queries;
  3. Having file based cache allows me to create a folder per database and then reset it by tags, having tags allows me to generate keys like md5 of a sql query.

Is something like this possible?

  1. memcache_set() - add tags parameter type text[] at the end
  2. memcache_flush_tags(tags text[], optional policy smallint) - new function, policy can be ALL or ANY tags.

Thank you in advance.

@saaros
Copy link
Member

saaros commented Dec 21, 2015

I don't think the flush command in memcache supports tags, so you'd have to delete all individual keys separately which is pretty clumsy. You could, however, just create your own wrapper functions around pgmemcache that use your custom tags in all operations and just update the tag when you want to stop using the values with the old tag.

One way to do it would be to have a table that contains your tag and SQL language functions that select that tag and prepend or append it to the key you're using. Another way would be to just embed that tag directly in your function definition.

One application I implemented had versioned database tables and functions and always stored values in the database in JSON format with the current software version included in the value. That way the keys remained the same across software versions (and different software versions running simultaneously wouldn't see different data), but if the software version on the frontend didn't match the version in the cached value the cache was ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants