Any distributed cache systems that allows for tagging content?

旧时模样 提交于 2019-12-12 11:10:11

问题


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


回答1:


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.




回答2:


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".




回答3:


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



来源:https://stackoverflow.com/questions/1378234/any-distributed-cache-systems-that-allows-for-tagging-content

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!