marconi-core-1.2.0.0: Modular indexing for rewindable ledger
Safe HaskellSafe-Inferred
LanguageHaskell2010

Marconi.Core.Transformer.WithCache

Description

A transformer that cache result of some queries

See Marconi.Core for documentation.

Synopsis

Documentation

data WithCache query indexer event #

Setup a cache for some requests.

The cache is active only for the latest Point. As a consequence, using WithCache is more effective on top of the on-disk part of a MixedIndexer, or any other part of an indexer that has a relatively stable sync point.

Instances

Instances details
(Ord query, Ord (Point event), IsSync m event index, MonadError (QueryError query) m, Monad m, Queryable m event query index) => Queryable m event query (WithCache query index) # 
Instance details

Defined in Marconi.Core.Transformer.WithCache

Methods

query :: Point event -> query -> WithCache query index event -> m (Result query) #

queryLatest :: query -> WithCache query index event -> m (Result query) #

(Applicative m, IsIndex m event index, Queryable m event query index) => IsIndex m event (WithCache query index) #

This instances update all the cached queries with the incoming event and then pass this event to the underlying indexer.

Instance details

Defined in Marconi.Core.Transformer.WithCache

Methods

index :: Timed (Point event) (Maybe event) -> WithCache query index event -> m (WithCache query index event) #

indexAll :: (Eq (Point event), Traversable f) => f (Timed (Point event) (Maybe event)) -> WithCache query index event -> m (WithCache query index event) #

indexAllDescending :: (Eq (Point event), Traversable f) => f (Timed (Point event) (Maybe event)) -> WithCache query index event -> m (WithCache query index event) #

rollback :: Point event -> WithCache query index event -> m (WithCache query index event) #

setLastStablePoint :: Point event -> WithCache query index event -> m (WithCache query index event) #

IsSync m event indexer => IsSync m event (WithCache query indexer) # 
Instance details

Defined in Marconi.Core.Transformer.WithCache

Methods

lastStablePoint :: WithCache query indexer event -> m (Point event) #

lastSyncPoint :: WithCache query indexer event -> m (Point event) #

(Monad m, Resetable m event index, HasGenesis (Point event), Ord (Point event), Queryable m event query index) => Resetable m event (WithCache query index) #

Rollback the underlying indexer, clear the cache, repopulate it with queries to the underlying indexer.

Instance details

Defined in Marconi.Core.Transformer.WithCache

Methods

reset :: WithCache query index event -> m (WithCache query index event) #

Closeable m indexer => Closeable m (WithCache query indexer) # 
Instance details

Defined in Marconi.Core.Transformer.WithCache

Methods

close :: WithCache query indexer event -> m () #

HasCacheConfig query (WithCache query indexer) # 
Instance details

Defined in Marconi.Core.Transformer.WithCache

Methods

cache :: Lens' (WithCache query indexer event) (Map query (Result query)) #

IndexerTrans (WithCache query) # 
Instance details

Defined in Marconi.Core.Transformer.WithCache

Methods

unwrap :: forall (indexer :: Type -> Type) event. Lens' (WithCache query indexer event) (indexer event) #

HasDatabasePath indexer => HasDatabasePath (WithCache query indexer) # 
Instance details

Defined in Marconi.Core.Transformer.WithCache

Methods

getDatabasePath :: WithCache query indexer event -> SQLiteDBLocation #

withCache #

Arguments

:: Ord query 
=> (Timed (Point event) (Maybe event) -> Result query -> Result query)

The cache update function

-> indexer event 
-> WithCache query indexer event 

A smart constructor for WithCache. The cache starts empty, you can populate it with addCacheFor

addCacheFor :: forall query m event indexer. Queryable (ExceptT (QueryError query) m) event query indexer => IsSync (ExceptT (QueryError query) m) event indexer => HasCacheConfig query indexer => Monad m => MonadError IndexerError m => Ord query => Ord (Point event) => query -> indexer event -> m (indexer event) #

Add a cache for a specific query.

When added, the WithCache queries the underlying indexer to populate the cache for this query.

If you want to add several indexers at the same time, use traverse.

class HasCacheConfig query indexer where #

Methods

cache :: Lens' (indexer event) (Map query (Result query)) #

Access to the cache

Instances

Instances details
(IndexerTrans t, HasCacheConfig query indexer) => HasCacheConfig query (t indexer) # 
Instance details

Defined in Marconi.Core.Transformer.WithCache

Methods

cache :: Lens' (t indexer event) (Map query (Result query)) #

HasCacheConfig query (WithCache query indexer) # 
Instance details

Defined in Marconi.Core.Transformer.WithCache

Methods

cache :: Lens' (WithCache query indexer event) (Map query (Result query)) #

(IndexerMapTrans t, HasCacheConfig query indexer) => HasCacheConfig query (t indexer output) # 
Instance details

Defined in Marconi.Core.Transformer.WithCache

Methods

cache :: Lens' (t indexer output event) (Map query (Result query)) #