I believe that deletion of dependent data can be done using memcached cas (check-and-set). Each value has a unique identifier (sequential). For each key, save another dependency key, which has a series of data and the keys of all dependents.
If you want to add a dependent, do
dependents, dep_serial = fetch(key+".dependents") data, serial = fetch(key) if serial != dependents[0]:
If the item is invalid, 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 if there are conflicting entries, these algorithms will eventually cease, since one writer will always βpassβ.
Martin v. LΓΆwis
source share