Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Persisted Cache for preheating on startup #2042

Closed
yuriy-yarosh opened this issue Feb 5, 2024 · 2 comments
Closed

Persisted Cache for preheating on startup #2042

yuriy-yarosh opened this issue Feb 5, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@yuriy-yarosh
Copy link

What is the problem this feature would solve?

I'd like to be able to cache requests to 3rd party API's and have a persisted cache across multiple program runs - it could be just a file persisted on disk and restored for in-mem cache preheating. A complete external cache e.g. redis/memcache would deserve a standalone custom implementation, but for preheating support and small frequent requests (e.g. Github API calls, for instance), a persisted file backed one makes perfect sense.

What is the feature you are proposing to solve the problem?

It worth making the existing CacheImpl a bit more modular, so it would accept custom CacheState implementations (with custom initialState) with some form of optional persistence.

What alternatives have you considered?

Making a custom Persisted Cache from scratch.

It makes sense to Drop MutableHashMap out of cache state entirely and replace it with the respective get/set semantics for an external caching, in case of Redis/Memcached, but I'd leave it for in-mem store otherwise.

export interface CacheState<in out Key, in out Error, in out Value> {
  map: MutableHashMap.MutableHashMap<Key, MapValue<Key, Error, Value>> /
@yuriy-yarosh yuriy-yarosh added the enhancement New feature or request label Feb 5, 2024
@mikearnaldi
Copy link
Member

Did you check

export const persisted = dual<
?

@yuriy-yarosh
Copy link
Author

@mikearnaldi nope, thanks.
This should work.

... should've asked at Discord instead

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants