Memcached依赖项

我正在使用memcahced(特别是Enyim memcached客户端),我希望能够在缓存中创建一个依赖于其他密钥的密钥,即如果密钥A依赖于密钥B,那么每当密钥B被删除或更改时,密钥A也无效。 如果可能的话,我还想确保在集群中的节点发生故障的情况下保持数据完整性,即如果密钥B在某个时刻不可用,如果密钥B变为无效,则密钥A仍应无效。 基于这篇文章我相信这是可能的,但我很难理解这个算法足以说服自己如何/为什么这样做。 谁能帮我吗?     
已邀请:
我最近一直在使用memcached并且我确定你正在尝试使用memcached“依旧”,但是需要从客户端处理。此外,数据复制应该发生在服务器端而不是客户端,这些是2个不同的域。 (至少使用memcached,看到它缺乏数据存储逻辑。但memcached的意思就是这样,极端的极简主义表现最好) 对于数据复制(针对物理故障集群节点的保护),您应该查看成员http://www.couchbase.org/get/couchbase/current。 对于deps算法,我可以在客户端看到类似的内容:对于任何给定的密钥,有一个可疑的附加密钥保存依赖密钥的列表/数组。
# - delete a key, recursive:
function deleteKey( keyname ):
    deps = client.getDeps( keyname ) #
    foreach ( deps as dep ):
        deleteKey( dep )
        memcached.delete( dep )
    endeach
    memcached.delete( keyname )
endfunction

# return the list of keynames or an empty list if the key doesnt exist
function client.getDeps( keyname ):
    return memcached.get( key_name + "_deps" ) or array()
endfunction

# Key "demokey1" and its counterpart "demokey1_deps". In the list of keys stored in
# "demokey1_deps" there is "demokey2" and "demokey3".
deleteKey( "demokey1" );
# this would first perform a memcached get on "demokey1_deps" then with the
# value returned as a list of keys ("demokey2" and "demokey3") run deleteKey()
# on each of them.
干杯     
我不认为这是一个直接的解决方案,但尝试在memcache密钥中创建一个名称空间系统,例如http://www.cakemail.com/namespacing-in-memcached/。简而言之,生成密钥并包含其他memcached密钥的当前值。在命名空间问题中,想法是使一系列在某个命名空间内的键无效。这是通过增加命名空间键的值来实现的,并且在重新生成键时引用先前命名空间值的任何键都不匹配。 您的问题看起来有点不同,但我认为通过将密钥A设置为密钥B“命名空间,如果节点B不可用,则计算密钥A的完整命名空间密钥,例如
"Key A|Key B:<whatever Key B value is>"
将返回false,从而允许您确定B不可用并使Key A的缓存查找无效。     

要回复问题请先登录注册