Giter Club home page Giter Club logo

Comments (6)

luisdavim avatar luisdavim commented on June 24, 2024 1

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.

luisdavim avatar luisdavim commented on June 24, 2024 1

https://redis.io/commands/expire#appendix-redis-expires

from bcache.

iwanbk avatar iwanbk commented on June 24, 2024 1

@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.

iwanbk avatar iwanbk commented on June 24, 2024 1

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 of expirationTimestamp. expiration timestamp in this new mechanism is error prone. (e.g.: use time.Now().Unix() instead of time.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.

iwanbk avatar iwanbk commented on June 24, 2024

Note that the underlying cache is LRU cache with max keys, so it won't going to unlimited number of keys

from bcache.

luisdavim avatar luisdavim commented on June 24, 2024

Sounds like a solid plan.

from bcache.

Related Issues (12)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.