Comments (6)
What about delaying the actual removal to when we try to get a deleted key? Or a garbage collector, similar to what redis does? Every x seconds it picks some random keys and if they are expired they get removed, in this case instead of looking for expired keys we'd look for keys marked as deleted.
from bcache.
https://redis.io/commands/expire#appendix-redis-expires
from bcache.
@luisdavim many thanks for the suggestion and the link, i'll definitely look into it.
The way expiration work this way is because my use case actually doesn't need any expiration.
But thinking about it again, bcache
will get more usage if it has similar behaviour with other common caches, it might need some API changes, but i think it is worth to do.
from bcache.
my plan for v0.2
key points:
- expiration will be handled by bcache, unlike v0.1 which basically do nothing with expiration
- passive key deletion. No GC-like mechanism at this phase, could be added later if needed
deletion delay
: add delay before actually delete the key, it is used to handle temporary network connection issue, which prevent data syncing between nodes- specify
ttl
instead ofexpirationTimestamp
.expiration timestamp
in this new mechanism is error prone. (e.g.: usetime.Now().Unix()
instead oftime.Now().UnixNano()
)
API changes:
- Set(key, val string, ttl int):
- ttl in seconds with no default value.
- ttl <=0 make it expired instantly
- Get(key string) (val string, exists bool)
- Delete(key string
, deleteDelay int):
DeletionDelay
will be added as field of Config
for New
:
- in seconds
- if
deleteDelay
<= 0, use default value
Let me know if you have any comments @luisdavim
from bcache.
Note that the underlying cache is LRU cache with max keys, so it won't going to unlimited number of keys
from bcache.
Sounds like a solid plan.
from bcache.
Related Issues (12)
- add cache filling mechanism
- add automatic peer ID assignment
- add credits
- message.Encode optimization HOT 4
- add cache value version
- provide benchmark data
- Add support for deleting keys HOT 6
- integration test: concurrent map iteration and map write
- Can support list ? HOT 3
- BCache + Linux Kernel 5.12 broken HOT 3
- Scaling limits and full examples? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bcache.