haxl-0.3.1.0: A Haskell library for efficient, concurrent, and concise data access.

Safe HaskellNone
LanguageHaskell2010

Haxl.Core.DataCache

Description

A cache mapping data requests to their results. This module is provided for access to Haxl internals only; most users should not need to import it.

Synopsis

Documentation

data DataCache res Source

The DataCache maps things of type f a to ResultVar a, for any f and a provided f a is an instance of Typeable. In practice f a will be a request type parameterised by its result.

See the definition of ResultVar for more details.

empty :: DataCache res Source

A new, empty DataCache.

insert Source

Arguments

:: (Hashable (req a), Typeable (req a), Eq (req a), Show (req a), Show a) 
=> req a

Request

-> res a

Result

-> DataCache res 
-> DataCache res 

Inserts a request-result pair into the DataCache.

insertNotShowable Source

Arguments

:: (Hashable (req a), Typeable (req a), Eq (req a)) 
=> req a

Request

-> res a

Result

-> DataCache res 
-> DataCache res 

Inserts a request-result pair into the DataCache, without requiring Show instances of the request or the result. The cache cannot be subsequently used with showCache.

lookup Source

Arguments

:: Typeable (req a) 
=> req a

Request

-> DataCache res 
-> Maybe (res a) 

Looks up the cached result of a request.

showCache :: DataCache ResultVar -> IO [(TypeRep, [(String, Either SomeException String)])] Source

Dumps the contents of the cache, with requests and responses converted to Strings using show. The entries are grouped by TypeRep. Note that this will fail if insertNotShowable has been used to insert any entries.