https://github.com/agrafix/caching-vault
Haskell: A vault-style cache implementation
https://github.com/agrafix/caching-vault
cache haskell vault
Last synced: 10 months ago
JSON representation
Haskell: A vault-style cache implementation
- Host: GitHub
- URL: https://github.com/agrafix/caching-vault
- Owner: agrafix
- License: bsd-3-clause
- Created: 2021-01-03T02:52:51.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2021-01-03T03:04:21.000Z (over 5 years ago)
- Last Synced: 2025-03-17T21:13:49.903Z (about 1 year ago)
- Topics: cache, haskell, vault
- Language: Haskell
- Homepage: https://hackage.haskell.org/package/caching-vault
- Size: 7.81 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# caching-vault
A simple [vault](https://hackage.haskell.org/package/vault) style cache implementation based on [stm-containers](https://hackage.haskell.org/package/stm-containers).
## Example
``` haskell
import Data.Time
import qualified Data.Cache.Vault as C
main :: IO ()
main =
do cache <- C.newCache
let key :: C.Key String
key = C.mintLabeledKey "foo"
C.insert key Nothing "cached value" cache
now <- getCurrentTime
value <- C.lookup now key cache
case value of
Nothing -> putStrLn "Cache miss"
Just val -> putStrLn ("Cache value is: " <> val)
```