registry-0.1.2.2: data structure for assembling components

Safe HaskellNone
LanguageHaskell2010

Data.Registry.Internal.Cache

Description

Cache for individual IO values when we wish to make singletons for database connection pools for example

This is inspired by https://hackage.haskell.org/package/io-memoize

Synopsis

Documentation

newtype Cache a Source #

A thread-safe write-once cache. If you need more functionality, (e.g. multiple write, cache clearing) use an MVar instead.

Constructors

Cache (MVar (Maybe a)) 
Instances
Eq (Cache a) Source # 
Instance details

Defined in Data.Registry.Internal.Cache

Methods

(==) :: Cache a -> Cache a -> Bool #

(/=) :: Cache a -> Cache a -> Bool #

fetch :: forall a m. MonadIO m => Cache a -> m a -> m a Source #

Fetch the value stored in the cache, or call the supplied fallback and store the result, if the cache is empty.

newCache :: IO (Cache a) Source #

Create an empty cache.