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]
Modules
[Index] [Quick Jump]
Downloads
- lazy-cache-0.2.0.0.tar.gz [browse] (Cabal source package)
- Package description (as included in the package)
Maintainer's Corner
For package maintainers and hackage trustees
Candidates
Versions [RSS] | 0.2.0.0 |
---|---|
Change log | CHANGELOG.md |
Dependencies | base (>=4.12 && <5), clock (>=0.8), hashable (>=1.1.2.3 && <1.5), psqueues (>=0.2 && <0.3) [details] |
Tested with | ghc ==9.2.2 || ==8.10.7 |
License | MPL-2.0 |
Copyright | 2019-2022 (C) Фонд "Талант и Успех" |
Author | Alexander Vershilov |
Maintainer | backend-dev@sirius.online |
Category | System |
Source repo | head: git clone https://github.com/cheopslab/lazy-cache |
Uploaded | by AlexanderVershilov at 2023-01-06T06:54:59Z |
Distributions | NixOS:0.2.0.0 |
Downloads | 94 total (7 in the last 30 days) |
Rating | (no votes yet) [estimated by Bayesian average] |
Your Rating | |
Status | Docs uploaded by user Build status unknown [no reports yet] |