Comments (1)
The ItemRemoved
event has both key and value - probably not the most convenient but gives you a way to observe removed values without a false lookup that can pollute cache ordering.
This is complicated by the lifetime of IDisposable
values. If values are disposable, the cache will auto dispose them on removal. A TryRemove
that returns the value would then either need to be a special case, where the caller must dispose the live value returned (which isn't intuitive, and likely one might forget and leak objects), or it would return disposed objects, which may not be valid and may throw if methods are invoked etc. Neither option is great. My rationale here was to do the simplest thing and not expose any potential traps.
The ItemRemoved
event fires before disposal, so the value is still alive when the event handler runs. Thus it sidesteps the above.
I suspect caching IDisposable
is less common, so it's unfortunate to limit the common case to keep this clean, but that was my tradeoff.
Changing the signature would be a breaking change - I will consider for the next major version, but I'm inclined not to add this.
from bitfaster.caching.
Related Issues (20)
- Serialise contents of LRU HOT 1
- [Feature request] - Enumerate all cached keys HOT 1
- Is it possible to add a method where it'll provide rough memory that is being used by the cache stance? HOT 2
- Is there a way to dump all values in the cache? HOT 1
- FastConcurrentTLru's Constructor timetolive is not precise on liunx mac platform HOT 7
- Any plans to evict expired items on the background? HOT 2
- Expiration based on a Value's property? HOT 2
- NuGet package is missing intellisense xml file HOT 1
- Use NonBlocking instead of ConcurrentDictionary HOT 1
- [Feature request] individual items expiry HOT 1
- Current time provider HOT 6
- [Feature request] Allow to pass additional factory argument to the `GetOrAdd`/`GetOrAddAsync` cache methods HOT 2
- Entry left in cache configured with WithAtomicGetOrAdd when value factory throws HOT 4
- [Feature request] Atomic TryRemove HOT 3
- [Feature request] Expire after access LRU HOT 5
- [Feature request] Add MRU cache HOT 3
- [Bug] Cold queue increases infinitely for some partitions and cache sizes HOT 3
- [Feature Request] Add TryRemove(KeyValuePair<K, V>) overload HOT 2
- Clearing LFU cache doesn't actually clear it HOT 9
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 bitfaster.caching.