Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- data CacheConfig = CacheConfig {}
- data CacheEnv m blk h
- checkInvariants ∷ Word32 → Cached blk → Maybe String
- newEnv ∷ (HasCallStack, ConvertRawHash blk, IOLike m, StandardHash blk, Typeable blk) ⇒ HasFS m h → ResourceRegistry m → Tracer m TraceCacheEvent → CacheConfig → ChunkInfo → ChunkNo → m (CacheEnv m blk h)
- expireUnusedChunks ∷ (HasCallStack, IOLike m) ⇒ CacheEnv m blk h → m Void
- close ∷ IOLike m ⇒ CacheEnv m blk h → m ()
- restart ∷ (ConvertRawHash blk, IOLike m, StandardHash blk, Typeable blk) ⇒ CacheEnv m blk h → ChunkNo → m ()
- appendOffsets ∷ (HasCallStack, Foldable f, IOLike m) ⇒ CacheEnv m blk h → Handle h → f SecondaryOffset → m ()
- openPrimaryIndex ∷ (HasCallStack, ConvertRawHash blk, IOLike m, StandardHash blk, Typeable blk) ⇒ CacheEnv m blk h → ChunkNo → AllowExisting → m (Handle h)
- readFirstFilledSlot ∷ (HasCallStack, ConvertRawHash blk, IOLike m, StandardHash blk, Typeable blk) ⇒ CacheEnv m blk h → ChunkNo → m (Maybe RelativeSlot)
- readOffsets ∷ (HasCallStack, ConvertRawHash blk, IOLike m, StandardHash blk, Typeable blk, Traversable t) ⇒ CacheEnv m blk h → ChunkNo → t RelativeSlot → m (t (Maybe SecondaryOffset), Maybe (StrictSeq SecondaryOffset))
- appendEntry ∷ ∀ m blk h. (HasCallStack, ConvertRawHash blk, IOLike m) ⇒ CacheEnv m blk h → ChunkNo → Handle h → Entry blk → m Word64
- readAllEntries ∷ ∀ m blk h. (HasCallStack, ConvertRawHash blk, IOLike m, StandardHash blk, Typeable blk) ⇒ CacheEnv m blk h → SecondaryOffset → ChunkNo → (Entry blk → Bool) → Word64 → IsEBB → m [WithBlockSize (Entry blk)]
- readEntries ∷ ∀ m blk h t. (HasCallStack, ConvertRawHash blk, IOLike m, StandardHash blk, Typeable blk, Traversable t) ⇒ CacheEnv m blk h → ChunkNo → t (IsEBB, SecondaryOffset) → m (t (Entry blk, BlockSize))
Environment
data CacheConfig Source #
CacheConfig | |
|
Instances
Show CacheConfig Source # | |
Defined in Ouroboros.Consensus.Storage.ImmutableDB.Impl.Index.Cache showsPrec ∷ Int → CacheConfig → ShowS # show ∷ CacheConfig → String # showList ∷ [CacheConfig] → ShowS # | |
Eq CacheConfig Source # | |
Defined in Ouroboros.Consensus.Storage.ImmutableDB.Impl.Index.Cache (==) ∷ CacheConfig → CacheConfig → Bool # (/=) ∷ CacheConfig → CacheConfig → Bool # |
∷ (HasCallStack, ConvertRawHash blk, IOLike m, StandardHash blk, Typeable blk) | |
⇒ HasFS m h | |
→ ResourceRegistry m | |
→ Tracer m TraceCacheEvent | |
→ CacheConfig | |
→ ChunkInfo | |
→ ChunkNo | Current chunk |
→ m (CacheEnv m blk h) |
Creates a new CacheEnv
and launches a background thread that expires
unused past chunks (expireUnusedChunks
).
PRECONDITION: $sel:pastChunksToCache:CacheConfig
(in CacheConfig
) > 0
Background thread
expireUnusedChunks ∷ (HasCallStack, IOLike m) ⇒ CacheEnv m blk h → m Void Source #
Intended to run as a background thread.
Will expire past chunks that haven't been used for $sel:expireUnusedAfter:CacheConfig
from
the cache.
Operations
close ∷ IOLike m ⇒ CacheEnv m blk h → m () Source #
Stops the background expiration thread.
This operation is idempotent.
∷ (ConvertRawHash blk, IOLike m, StandardHash blk, Typeable blk) | |
⇒ CacheEnv m blk h | |
→ ChunkNo | The new current chunk |
→ m () |
Restarts the background expiration thread, drops all previously cached information, loads the given chunk.
PRECONDITION: the background thread expiring unused past chunks must have been terminated.
On the primary index
appendOffsets ∷ (HasCallStack, Foldable f, IOLike m) ⇒ CacheEnv m blk h → Handle h → f SecondaryOffset → m () Source #
openPrimaryIndex ∷ (HasCallStack, ConvertRawHash blk, IOLike m, StandardHash blk, Typeable blk) ⇒ CacheEnv m blk h → ChunkNo → AllowExisting → m (Handle h) Source #
This is called when a new chunk is started, which means we need to update
Cached
to reflect this.
readFirstFilledSlot ∷ (HasCallStack, ConvertRawHash blk, IOLike m, StandardHash blk, Typeable blk) ⇒ CacheEnv m blk h → ChunkNo → m (Maybe RelativeSlot) Source #
readOffsets ∷ (HasCallStack, ConvertRawHash blk, IOLike m, StandardHash blk, Typeable blk, Traversable t) ⇒ CacheEnv m blk h → ChunkNo → t RelativeSlot → m (t (Maybe SecondaryOffset), Maybe (StrictSeq SecondaryOffset)) Source #
On the secondary index
appendEntry ∷ ∀ m blk h. (HasCallStack, ConvertRawHash blk, IOLike m) ⇒ CacheEnv m blk h → ChunkNo → Handle h → Entry blk → m Word64 Source #
readAllEntries ∷ ∀ m blk h. (HasCallStack, ConvertRawHash blk, IOLike m, StandardHash blk, Typeable blk) ⇒ CacheEnv m blk h → SecondaryOffset → ChunkNo → (Entry blk → Bool) → Word64 → IsEBB → m [WithBlockSize (Entry blk)] Source #
readEntries ∷ ∀ m blk h t. (HasCallStack, ConvertRawHash blk, IOLike m, StandardHash blk, Typeable blk, Traversable t) ⇒ CacheEnv m blk h → ChunkNo → t (IsEBB, SecondaryOffset) → m (t (Entry blk, BlockSize)) Source #