Safe Haskell | None |
---|---|
Language | Haskell2010 |
By tracing operations we can transform one type of cache into another.
Synopsis
- data Cache m k t v = Caching c m k t v => Cache c
- insert :: (Monad m, Caching c m k () v) => c -> k -> v -> m ()
- lookup :: (MonadFail m, Caching c m k t v) => c -> k -> m v
- lookupMaybe :: (Monad m, Caching c m k t v) => c -> k -> m (Maybe v)
- lookupCreating :: (Monad m, Caching c m k () v) => c -> k -> m v -> m v
- cached :: (Monad m, Caching c m k t v) => c -> k -> m Bool
- evict :: (Monad m, Caching c m k t v) => c -> k -> m ()
- data CacheEvent k t v
- = CacheEvict {
- _ceKey :: !k
- _ceTracking :: !t
- _ceValue :: v
- | CacheAdd {
- _ceKey :: !k
- _ceTracking :: !t
- _ceValue :: v
- = CacheEvict {
- type CacheTrace k t v = DList (CacheEvent k t v)
- class Caching c (m :: * -> *) k t v | c -> m, c -> k, c -> t, c -> v where
- insetTraced :: forall (trc :: Bool). c -> k -> t -> v -> Tracable trc (CacheTrace k t v) m ()
- lookupTraced :: forall (trc :: Bool). c -> k -> Tracable trc (CacheTrace k t v) m (Maybe v)
- evictTraced :: forall (trc :: Bool). c -> k -> Tracable trc (CacheTrace k t v) m ()
- updateTracking :: forall (trc :: Bool). c -> k -> (t -> t) -> Tracable trc (CacheTrace k t v) m ()
- data DictCache (m :: * -> *) k t v = DictCache {
- dcIns :: forall (trc :: Bool). k -> t -> v -> Tracable trc (CacheTrace k t v) m ()
- dcLook :: forall (trc :: Bool). k -> Tracable trc (CacheTrace k t v) m (Maybe v)
- dcEvict :: forall (trc :: Bool). k -> Tracable trc (CacheTrace k t v) m ()
- dcUp :: forall (trc :: Bool). k -> (t -> t) -> Tracable trc (CacheTrace k t v) m ()
Documentation
lookupCreating :: (Monad m, Caching c m k () v) => c -> k -> m v -> m v Source #
data CacheEvent k t v Source #
CacheEvict | |
| |
CacheAdd | |
|
Instances
type CacheTrace k t v = DList (CacheEvent k t v) Source #
class Caching c (m :: * -> *) k t v | c -> m, c -> k, c -> t, c -> v where Source #
c - The cache type. m - The Monad. k - The key. t - The tracking data. This allows caches to store metadata for 3rd parties. v - The value.
insetTraced :: forall (trc :: Bool). c -> k -> t -> v -> Tracable trc (CacheTrace k t v) m () Source #
lookupTraced :: forall (trc :: Bool). c -> k -> Tracable trc (CacheTrace k t v) m (Maybe v) Source #
evictTraced :: forall (trc :: Bool). c -> k -> Tracable trc (CacheTrace k t v) m () Source #
updateTracking :: forall (trc :: Bool). c -> k -> (t -> t) -> Tracable trc (CacheTrace k t v) m () Source #
Instances
Caching (DictCache m k t v) m k t v Source # | |
Defined in Data.Cache.Type insetTraced :: DictCache m k t v -> k -> t -> v -> Tracable trc (CacheTrace k t v) m () Source # lookupTraced :: DictCache m k t v -> k -> Tracable trc (CacheTrace k t v) m (Maybe v) Source # evictTraced :: DictCache m k t v -> k -> Tracable trc (CacheTrace k t v) m () Source # updateTracking :: DictCache m k t v -> k -> (t -> t) -> Tracable trc (CacheTrace k t v) m () Source # |
data DictCache (m :: * -> *) k t v Source #
A reified Caching dictionary so that we can assemble them on demand.
DictCache | |
|
Instances
Caching (DictCache m k t v) m k t v Source # | |
Defined in Data.Cache.Type insetTraced :: DictCache m k t v -> k -> t -> v -> Tracable trc (CacheTrace k t v) m () Source # lookupTraced :: DictCache m k t v -> k -> Tracable trc (CacheTrace k t v) m (Maybe v) Source # evictTraced :: DictCache m k t v -> k -> Tracable trc (CacheTrace k t v) m () Source # updateTracking :: DictCache m k t v -> k -> (t -> t) -> Tracable trc (CacheTrace k t v) m () Source # |