gpt4 book ai didi

caching - Memcached 依赖项

转载 作者:行者123 更新时间:2023-12-04 12:00:08 25 4
gpt4 key购买 nike

我正在使用 memcahced (特别是 Enyim memcached client ),我希望能够使缓存中的键依赖于其他键,即如果 A键依赖于 key B ,然后每当 key B 被删除或更改, A键也失效了。

如果可能的话,我还想确保在集群中的节点发生故障的情况下保持数据完整性,即如果 key B 有时不可用, A键如果 仍然无效B键应该无效。

基于 this post我相信这是可能的,但我正在努力理解算法以说服自己如何/为什么这样做。

谁能帮我吗?

最佳答案

我最近一直在使用 memcached,而且我确信你试图用依赖做的事情不可能用 memcached“按原样”处理,但需要从客户端处理。此外,数据复制应该发生在服务器端,而不是来自客户端,这是 2 个不同的域。 (至少使用 memcached,看到它缺乏数据存储逻辑。memcached 的重点就是这样,为了更好的性能,极端极简主义)

对于数据复制(防止物理故障集群节点),您应该查看 membased 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.

干杯

关于caching - Memcached 依赖项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5141569/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com