Comments (2)
Can you elaborate a bit more what you're suggesting?
from cache2go.
Every expirationCheck will iterate all items including the permanent items and and non-permanent items. I think it unnecessary to check the permanent items, why not store them to another map so that the expirationCheck checks the non-permanent items only.
Plus..
I think that using cleanupInterval to check the expiration is not that efficient.
Like this example:
Add an item with lifespan = 10 to a blank table, the cleanupInterval will be 10s,
6s later, add another item with lifespan = 8, it will call the table.expirationcheck()
because item.lifespan < cleanupInteval
in fact, it's unnecessary to check because 10 - 6 < 8 (the cleanupTimer countdown to 10-6 = 4) .
In a nutshell, the cleanupTimer is really close to call expirationCheck as time goes by, however, the cleanupInterval remains unchanged!
Since we couldn't get the countdown time of the cleanupTimer directly, note down the cleaning time as cleanupTime is helpful to make it.
I submit a PR. If I was wrong please correct me and I will be really grateful. Thank you in advance!
from cache2go.
Related Issues (20)
- Question about SetAddedItemCallback HOT 3
- Allow for setting an upper limit on memory usage HOT 2
- if registered dataload, Value() not thread safe HOT 2
- expirationCheck optimization ,use lazy and timeAfter check , just like redis key expired policy
- table.addedItem does not need to be a array HOT 1
- is item.RLock() among table.items‘s traversal in expirationCheck() necessary? HOT 3
- [bug]: delete operation in Foreach causes a deadlock HOT 3
- May I ask why using the go rountine in the time.AfterFunc, the param func should be run by an rountine HOT 2
- how about expire an item on the timestamp being added into the table other then the last time being accessed HOT 1
- Why creating a Cache requires Double check whether the table exists or not. HOT 1
- Panic occurs when you use the new create struct to access the key HOT 1
- CacheTable.Add() should not use “defer table.unlock ”
- addInternal() call expirationCheck() is not a good idea HOT 1
- Support deploy in distribution environment? HOT 5
- I hope to provide a method: get the value but not update the expiration time HOT 5
- please deletion based on createtime.
- PR to get cached value without updating it's keep alive HOT 1
- [Feature Request] Change item lifeSpan HOT 1
- Proposal to Integrate SIEVE Eviction Algorithm
- Proposal: implement a function that returns a cache retrieval function with a specific type
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 cache2go.