pub trait Cache<Block: BlockT>: Send + Sync {
    fn initialize(&self, key: &Id, value_at_genesis: Vec<u8>) -> Result<()>;
fn get_at(
        &self,
        key: &Id,
        block: &BlockId<Block>
    ) -> Result<Option<((NumberFor<Block>, Block::Hash), Option<(NumberFor<Block>, Block::Hash)>, Vec<u8>)>>; }
Expand description

Blockchain optional data cache.

Required methods

Initialize genesis value for the given cache.

The operation should be performed once before anything else is inserted in the cache. Otherwise cache may end up in inconsistent state.

Returns cached value by the given key.

Returned tuple is the range where value has been active and the value itself. Fails if read from cache storage fails or if the value for block is discarded (i.e. if block is earlier that best finalized, but it is not in canonical chain).

Implementors