Giter Club home page Giter Club logo

Comments (4)

karlseguin avatar karlseguin commented on July 23, 2024

It'll evict the data asynchronously. Every cache instance has a "worker" goroutine which does all of the housecleaning. This way, the main get/set path doesn't have to lock the linked list.

To be clear, the cleanup isn't periodic (e.g. every 5 seconds or something), it is triggered by the 4th put, but there's no limit on how large the cache could grow before things are actually evicted.

from ccache.

TeqGin avatar TeqGin commented on July 23, 2024

It'll evict the data asynchronously. Every cache instance has a "worker" goroutine which does all of the housecleaning. This way, the main get/set path doesn't have to lock the linked list.

To be clear, the cleanup isn't periodic (e.g. every 5 seconds or something), it is triggered by the 4th put, but there's no limit on how large the cache could grow before things are actually evicted.

Thanks you. I got it. But by this design wouldn't make the MaxSize() a little confusing? I mean if I set the maxsize to n, actually I don't want the cache capability exceed more than n.
So in this situation, say if cache's capability initial as 1000, and someone add 1001 element to the cache, will capability grow to 1500? and after the "worker" goroutine finish its job, will the capability shrink back to 1000? In my case I wish the cache don't grow too much, best to keep the cache in my expected size.

from ccache.

karlseguin avatar karlseguin commented on July 23, 2024

Using buffered channels to limit contention on the hot path is fundamental to this library.

However, are you able to look at the new setable_buffer branch?

It adds a new configuration option, SetableBuffer(INT). If you set this to 0, then the max size shoudl be MaxSize + 1.

This could have been achieved by setting the existing PromoteBuffer(int) configuration option to 0, but that could have significantly hurt the performance of Gets. So I created a new channel for sets, which behaves like the existing promotable buffer, but which can have its own separate capacity.

Note that setting SetableBuffer(0) will slow down writes even if the cache has room. Personally, I'd recommend at least a small buffer and decreasing your MaxSize accordingly.

from ccache.

TeqGin avatar TeqGin commented on July 23, 2024

Very amazing of your work. Thanks you very much.
Yes, I will take a look of the stable_buffer branch.

from ccache.

Related Issues (20)

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.