caching-vault: A vault-style cache implementation

[ bsd3, data, library ] [ Propose Tags ] [ Report a vulnerability ]

Allows a central cache for arbitrary values with expiry dates


[Skip to Readme]

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0
Dependencies base (>=4.7 && <5), stm, stm-containers, text, time [details]
License BSD-3-Clause
Copyright 2021 Alexander Thiemann
Author Alexander Thiemann
Maintainer Alexander Thiemann <mail@thiemann.at>
Category Data
Home page https://github.com/agrafix/caching-vault#readme
Bug tracker https://github.com/agrafix/caching-vault/issues
Source repo head: git clone https://github.com/agrafix/caching-vault
Uploaded by AlexanderThiemann at 2021-01-03T03:03:47Z
Distributions NixOS:0.1.0.0
Downloads 271 total (6 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2021-01-03 [all 1 reports]

Readme for caching-vault-0.1.0.0

[back to package description]

caching-vault

A simple vault style cache implementation based on stm-containers.

Example

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)