Comments (3)
Agree this is useful - I will look at adding two methods:
- TryUpdate(key, value)
- AddOrUpdate(key, value)
The first option can be used in cases where you know a value is changed, but not whether it is cached. So you can try to update it, and if it's not cached the cache will not be polluted.
The second option is effectively a Put, and could be used to seed the cache as you described.
Regarding the GetOrAdd method and the lambda throwing an exception - if it throws nothing is cached and the exception is not caught by the cache code, I assume the caller would catch and take steps to recover. I haven't tried but believe if the lambda returns null, null will be cached.
from bitfaster.caching.
Those additions sound great
from bitfaster.caching.
Merged implementations of both TryUpdate and GetOrAdd. They will be in the next package update.
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 TryRemove(K, out V) overload HOT 1
- [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
- [Feature] Add event for when an item is expired. HOT 6
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.