InCerryGit / FasterKvCache

FasterKv.Cache is an in-process hybrid cache library (memory+disk) based on the Microsoft FasterKv.
MIT License
109 stars 17 forks source link

能否增加GetOrAdd支持。当然我没怎么用过Cache,因此最佳实践也不知道应该是怎样的。 #10

Closed sgf closed 1 year ago

sgf commented 1 year ago

Description

[Description of the bug or feature]

能否增加GetOrAdd支持。当然我没怎么用过Cache,因此最佳实践也不知道应该是怎样的。

Related code

GetOrAdd(key,()=> db.find(xxx); )
InCerryGit commented 1 year ago

完全是可以支持的,只是我对于这个函数的语义有一些疑问,我们应不应该保证GetOrAdd是原子性? 如果不保证:key不存在是,多线情况下访问key,db.find(xxxx)可能会执行多次。

InCerryGit commented 1 year ago

该功能已经得到支持,可以下载 1.0.1-rc1 版本进行适用,如果没有其它问题,会在后面发布正式版 @sgf