Comments (4)
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.
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.
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.
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)
- Fetch() is not atomic HOT 2
- ability to set an item that never expires HOT 2
- would like a version of Fetch that doesn't require a closure HOT 4
- Stop can cause race detector errors in testing HOT 14
- Bug report: item leak when c.promotables is busy HOT 1
- Bug report: TrackingGet goroutine unsafe with onDelete func HOT 1
- How to get the max performance? HOT 3
- Not Promote on Get HOT 2
- How to promote directly saved item? HOT 1
- OnDelete not called in LayeredCache.gc
- High lock contention in LayeredCache.set with few primary keys HOT 1
- memory leak HOT 3
- New release implemented via generics? HOT 1
- Bug Report: v3.0.0 gc may failed HOT 5
- Bug Report: v3.0.1 gc may failed
- Memory leak during cleanup
- Generic key type HOT 2
- ttl not working HOT 4
- Fix flaky test 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 ccache.