Skip to main content

Module cache

Module cache 

Source
Expand description

In-memory cache for market and execution data, with optional persistent backing.

Provides methods to load, query, and update cached data such as instruments, orders, and prices.

§Persistence policy

Cache operations complete valid in-memory changes independently of optional persistence. All cache writes, including indexes, snapshots, component state, heartbeats, and purge deletions, log persistence failures at ERROR without propagating them or interrupting event and command processing. Validation and in-memory errors still propagate, including DeFi currency integrity errors reported by a backing database. The cache also propagates read, restoration, and explicit database flush errors returned by its backing.

A successful cache call confirms the cache operation, not queue admission or durable storage. For queued backings, database writes can fail after the cache call returns. Both enqueue and downstream write failures are logged as persistence failures.

The node or backtest shutdown_on_error setting requests a normal shutdown on Rust error logs emitted after the runtime starts, including persistence failures. It does not abort the process or roll back the current operation. Error-triggered shutdown handling is disabled before final component-state saves, which still follow this best-effort policy.

Re-exports§

pub use config::CacheConfig;
pub use refs::AccountRef;
pub use refs::AccountRefMut;
pub use refs::OrderRef;
pub use refs::OrderRefMut;
pub use refs::PositionRef;
pub use refs::PositionRefMut;

Modules§

config
database
Provides a Cache database backing.
fifo
Bounded FIFO caches for tracking IDs and key-value pairs with O(1) lookups.
quote
Generic quote cache for maintaining the last known quote per instrument.
refs
Lifetime-scoped reference newtypes for values held in the platform cache.

Structs§

Cache
A common in-memory Cache for market and execution related data.
CacheApi
User-facing cache API.
CacheSnapshotRef
Cache-owned reference to a snapshot blob.
CacheView
Read-only view over the platform cache.
VenueOrderIdOwnershipError
Error returned when a venue order ID is already owned by another client order.

Enums§

AccountLookupError
Error returned when an account cannot be resolved from a cache or store.
CurrencyLookupError
Error returned when a currency cannot be resolved from a cache or store.
InstrumentLookupError
Error returned when an instrument cannot be resolved from a cache or store.
OrderBookLookupError
Error returned when an order book cannot be resolved from a cache or store.
OrderListLookupError
Error returned when an order list cannot be resolved from a cache or store.
OrderLookupError
Error returned when an order cannot be resolved from a cache or store.
OwnOrderBookLookupError
Error returned when an own order book cannot be resolved from a cache or store.
PositionLookupError
Error returned when a position cannot be resolved from a cache or store.
SyntheticInstrumentLookupError
Error returned when a synthetic instrument cannot be resolved from a cache or store.

Constants§

ACCOUNT_NOT_FOUND
Message used for a missing account lookup.
CURRENCY_NOT_FOUND
Message used for a missing currency lookup.
INSTRUMENT_NOT_FOUND
Message used for a missing instrument lookup.
ORDER_BOOK_NOT_FOUND
Message used for a missing order book lookup.
ORDER_LIST_NOT_FOUND
Message used for a missing order list lookup.
ORDER_NOT_FOUND
Message used for a missing order lookup.
OWN_ORDER_BOOK_NOT_FOUND
Message used for a missing own order book lookup.
POSITION_NOT_FOUND
Message used for a missing position lookup.
SYNTHETIC_INSTRUMENT_NOT_FOUND
Message used for a missing synthetic instrument lookup.