lazy-cache: Library for caching IO action that leverages on GHC RTS implementation
The library provides an interface for caching the results of IO actions. This library relies on a blackholing — mechanism that is used to implement lazy evaluation for avoiding concurrent runs of the action (this is where the name of the library comes from).
The library provides caching mechanismsl with the following properties:
when the function is called the successful result is cached by no more than a provided time;
if the function ends with an exception, it will be rethrown, and the result will not be cached;
if the function will be called with the same input value it immediately gets cached result;
if functions are called concurrently with the different input values they will not block each other;
if functions will be called concurrently with the same argument then only one will act, others will wait until the first one is finished and will either return the result once it's received, or will rethrow an exception if the first one exits with an exception;
outdated values are cleared only on accesses to the cache, so if no action is called the data will not be cleared.
The main entry point of the library is System.Cache module, it explains how to use the library and provides the public API, that does not depend on the actual store implementation.
The library provides an interface for caching, and three implementations:
System.Cache.Impl.Ghc — the main one based on GHC system;
System.Cache.Impl.MVar — implementation based on library functions;
System.Cache.Impl.NoCache — implementation that disables caching, but keeps the same interface
If you want to implement your own caching mechanism, or use internal API, you can refer to the System.Cache.Internal.Interface module for an additional documentation.
[Skip to Readme]
[Index] [Quick Jump]
- lazy-cache-0.2.0.0.tar.gz [browse] (Cabal source package)
- Package description (as included in the package)
For package maintainers and hackage trustees
|Dependencies||base (>=4.12 && <5), clock (>=0.8), hashable (>=184.108.40.206 && <1.5), psqueues (>=0.2 && <0.3) [details]|
|Copyright||2019-2022 (C) Фонд "Талант и Успех"|
|Source repo||head: git clone https://github.com/cheopslab/lazy-cache|
|Uploaded||by AlexanderVershilov at 2023-01-06T06:54:59Z|
|Downloads||29 total (3 in the last 30 days)|
|Rating||(no votes yet) [estimated by Bayesian average]|
|Status||Docs uploaded by user
Build status unknown [no reports yet]