Any distributed cache systems that allows for tagging content?
Asked Answered
E

3

5

I'd like to know if there is any distributed cache systems like memcached, velocity or sharedcache that allows me to tag content with more than just it's name, or that can relate items to eachother, so if i invalidate the cache for one item it also invalidates the related items too.

eg. if i have two pages that reference the same data and that data changes, i'd like the cache for the two referencing pages to invalidate.

  • or is this an addition to one of those projects begging to be developed? :)

edit: i'm on asp.net

Edh answered 4/9, 2009 at 9:45 Comment(1)
I too would be interested in this - good question.Purington
P
0

Velocity has support for tagging where each tag is a string. Objects can be retrieved by a tag or by multiple tags e.g. 'Condiment' AND 'Free Delivery'.

However Velocity has no support for dependencies - IIRC the Velocity team have said dependencies will not be in v1.

Paulo answered 6/9, 2009 at 21:43 Comment(2)
maybe i'll look into velocity then, but my guts tell me that memcache is the way to go :)Edh
i'll flag this as the solution.Edh
R
3

I believe that deletion of dependent data can be done using memcached's cas (check-and-set) operation. Each value has a unique ID (serial). For each key, store another key.dependents, which has the serial of the data, and the keys of all dependents.

When going to add a dependent, do

dependents, dep_serial = fetch(key+".dependents")
data, serial = fetch(key)
if serial != dependents[0]:
    # somebody changed the actual data
    start_over
generate_and_cache_dependent(dep_key, data)
dependents.append(dep_key)
if not cas(dependents, dep_serial):
   # somebody changed dependents
   start_over # can avoid regenerating the data if they are still at serial

When invalidating an item, do

dependents, dep_serial = fetch(key + ".dependents")
serial = update(key, new_data)
for dkey in dependents[1:]:
    delete(dkey)
dependents = [serial]
if not cas(dependents, dep_serial):
    start_over

Even in the presence of conflicting writes, these algorithms will eventually terminate, since one writer will always "get through".

Rusert answered 4/9, 2009 at 11:11 Comment(1)
interesting, i'll look into that! but i'd really like to wrap it into something like set( 'section#1', 'section data', 'article#1,article#2,article#3' ) then just beeing able to delete('article#1'); and then when i try to get section1 the next time it just has to regenerate it, but that could possible create race-conditions and cache deadlocks, and those arent funny either :/Edh
P
0

Velocity has support for tagging where each tag is a string. Objects can be retrieved by a tag or by multiple tags e.g. 'Condiment' AND 'Free Delivery'.

However Velocity has no support for dependencies - IIRC the Velocity team have said dependencies will not be in v1.

Paulo answered 6/9, 2009 at 21:43 Comment(2)
maybe i'll look into velocity then, but my guts tell me that memcache is the way to go :)Edh
i'll flag this as the solution.Edh
S
0

implementing dependency is quite difficult, but maybe all other features of Shared Cache (http://www.sharedcache.com || http://sharedcache.codeplex.com) will fit your needs for caching.

regards, roni

Spoil answered 8/9, 2009 at 6:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.