Comments (4)
It's not currently possible, but I'd be happy to accept a PR if you can get to it before I have time to work on it. It would be pretty straightforward to add support to the TimedCache
and TimedSizedCache
to accept a subsecond_nanos
so the pair of (seconds, subsec_nanos) can be compared against the pair that makes a Duration
. Then there's several places in the impl of both cache types that need to be updated to include checking subsec nano (ex. here
and here
), and also adding a macro argument for it (around here
)
from cached.
@jaemk
I am interested in implementing this and submitting a pull request. Although I have a few implementation concerns/questions. I'm guessing that changing the outward facing API in a breaking way would be a concern of yours.
What should be done about the following functions to allow subsecond TTL?
- TimedCache::with_lifespan
- TimedCache::with_lifespan_and_capacity
- TimedCache::with_lifespan_and_refresh
- Cached::cache_lifespan
- Cached::cache_set_lifespan
New versions of all of these could be created with the ability to pass in a lifespan with additional subsecond_nanos, but the function names seem to get quite long and redundant. It also seems beneficial to switch the internal representation of the lifespan to a Duration.
It seems like it would be nice to just pass in a duration as the lifespan, but that would be a breaking API change.
from cached.
Related Issues (20)
- Disable caching for tests? HOT 2
- Upgrade redis to 0.22 HOT 1
- Cache an async function without calling `.await` HOT 8
- #![feature]` may not be used on the stable release channel from thiserror crate HOT 1
- Feature Request: Ignore certain function arguments HOT 7
- Errors seen while using AsyncRedisCache
- Inserting into SizedCache can cause the cache size to decrease HOT 4
- Is it completely impossible to cache generic functions? HOT 3
- Feature request: Skip self field to allow caching methods
- Cron-like cache clearing HOT 1
- Mio & Tokio causing wasm build to fail
- Consider only changing patch versions when making non breaking releases
- Feature Request: bool function argument that forces a cache refresh. HOT 2
- Update cached value asynchronously, outside the thread that returns the return value of the function HOT 1
- How to get all cached values? HOT 1
- Add feature for usage of `redis::aio::ConnectionManager` to help to recover from redis server restarts HOT 1
- `async_once` is unsound HOT 2
- Allow reexport
- sync_writes isn't working correctly when different values for function parameters are used HOT 5
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 cached.