pub struct RedisCacheDatabase {
pub con: ConnectionManager,
pub trader_id: TraderId,
pub trader_key: String,
pub encoding: SerializationEncoding,
pub bulk_read_batch_size: Option<usize>,
/* private fields */
}Fields§
§con: ConnectionManager§trader_id: TraderId§trader_key: String§encoding: SerializationEncoding§bulk_read_batch_size: Option<usize>Implementations§
Source§impl RedisCacheDatabase
impl RedisCacheDatabase
Sourcepub async fn new(
trader_id: TraderId,
instance_id: UUID4,
config: CacheConfig,
) -> Result<Self>
pub async fn new( trader_id: TraderId, instance_id: UUID4, config: CacheConfig, ) -> Result<Self>
Creates a new RedisCacheDatabase instance for the given trader_id, instance_id, and config.
§Errors
Returns an error if:
- The database configuration is missing in
config. - Establishing the Redis connection fails.
- The command processing task cannot be spawned.
pub const fn get_encoding(&self) -> SerializationEncoding
pub fn get_trader_key(&self) -> &str
pub fn close(&mut self)
pub async fn flushdb(&mut self)
Sourcepub fn flushdb_sync(&self) -> Result<()>
pub fn flushdb_sync(&self) -> Result<()>
Sends a flush command through the background task channel and blocks until it completes. Safe to call from any runtime context.
§Errors
Returns an error if the command channel is closed or the reply is lost.
Sourcepub async fn keys(&mut self, pattern: &str) -> Result<Vec<String>>
pub async fn keys(&mut self, pattern: &str) -> Result<Vec<String>>
Retrieves all keys matching the given pattern from Redis for this trader.
§Errors
Returns an error if the underlying Redis scan operation fails.
Sourcepub async fn read(&mut self, key: &str) -> Result<Vec<Bytes>>
pub async fn read(&mut self, key: &str) -> Result<Vec<Bytes>>
Reads the value(s) associated with key for this trader from Redis.
§Errors
Returns an error if the underlying Redis read operation fails.
Sourcepub async fn read_bulk(&mut self, keys: &[String]) -> Result<Vec<Option<Bytes>>>
pub async fn read_bulk(&mut self, keys: &[String]) -> Result<Vec<Option<Bytes>>>
Reads multiple values using bulk operations for efficiency.
§Errors
Returns an error if the underlying Redis read operation fails.
Sourcepub fn load_custom_data(&self, data_type: &DataType) -> Result<Vec<CustomData>>
pub fn load_custom_data(&self, data_type: &DataType) -> Result<Vec<CustomData>>
Loads custom data from Redis matching the given data_type (blocking).
Spawns the async query on the global Nautilus runtime and blocks until the result arrives via a channel. Safe from any thread context (Python, test runtimes, plain threads).
§Errors
Returns an error if the query fails or the reply channel is closed.
Sourcepub fn insert(&self, key: String, payload: Option<Vec<Bytes>>) -> Result<()>
pub fn insert(&self, key: String, payload: Option<Vec<Bytes>>) -> Result<()>
Sends an insert command for key with optional payload to Redis via the background task.
§Errors
Returns an error if the command cannot be sent to the background task channel.
Sourcepub fn add_custom_data(&self, data: &CustomData) -> Result<()>
pub fn add_custom_data(&self, data: &CustomData) -> Result<()>
Stores custom data in Redis (key format: custom:<ts_init_020>:<uuid>, value: full JSON).
§Errors
Returns an error if serialization fails or the insert command cannot be sent.
Sourcepub fn update(&mut self, key: String, payload: Option<Vec<Bytes>>) -> Result<()>
pub fn update(&mut self, key: String, payload: Option<Vec<Bytes>>) -> Result<()>
Sends an update command for key with optional payload to Redis via the background task.
§Errors
Returns an error if the command cannot be sent to the background task channel.
Sourcepub fn delete(&mut self, key: String, payload: Option<Vec<Bytes>>) -> Result<()>
pub fn delete(&mut self, key: String, payload: Option<Vec<Bytes>>) -> Result<()>
Sends a delete command for key with optional payload to Redis via the background task.
§Errors
Returns an error if the command cannot be sent to the background task channel.
Sourcepub fn delete_order(&self, client_order_id: &ClientOrderId) -> Result<()>
pub fn delete_order(&self, client_order_id: &ClientOrderId) -> Result<()>
Delete the given order from the database with full index cleanup.
§Errors
Returns an error if the command cannot be sent to the background task channel.
Sourcepub fn delete_position(&self, position_id: &PositionId) -> Result<()>
pub fn delete_position(&self, position_id: &PositionId) -> Result<()>
Delete the given position from the database with full index cleanup.
§Errors
Returns an error if the command cannot be sent to the background task channel.
Trait Implementations§
Source§impl Debug for RedisCacheDatabase
impl Debug for RedisCacheDatabase
Source§impl<'py> IntoPyObject<'py> for RedisCacheDatabase
impl<'py> IntoPyObject<'py> for RedisCacheDatabase
Source§type Target = RedisCacheDatabase
type Target = RedisCacheDatabase
Source§type Output = Bound<'py, <RedisCacheDatabase as IntoPyObject<'py>>::Target>
type Output = Bound<'py, <RedisCacheDatabase as IntoPyObject<'py>>::Target>
Source§fn into_pyobject(
self,
py: Python<'py>,
) -> Result<<Self as IntoPyObject<'_>>::Output, <Self as IntoPyObject<'_>>::Error>
fn into_pyobject( self, py: Python<'py>, ) -> Result<<Self as IntoPyObject<'_>>::Output, <Self as IntoPyObject<'_>>::Error>
Source§impl PyClass for RedisCacheDatabase
impl PyClass for RedisCacheDatabase
Source§impl PyClassImpl for RedisCacheDatabase
impl PyClassImpl for RedisCacheDatabase
Source§const IS_BASETYPE: bool = false
const IS_BASETYPE: bool = false
Source§const IS_SUBCLASS: bool = false
const IS_SUBCLASS: bool = false
Source§const IS_MAPPING: bool = false
const IS_MAPPING: bool = false
Source§const IS_SEQUENCE: bool = false
const IS_SEQUENCE: bool = false
Source§const IS_IMMUTABLE_TYPE: bool = false
const IS_IMMUTABLE_TYPE: bool = false
Source§const RAW_DOC: &'static CStr = c"\x00"
const RAW_DOC: &'static CStr = c"\x00"
Source§const DOC: &'static CStr
const DOC: &'static CStr
text_signature if a constructor is defined. Read moreSource§type Layout = <<RedisCacheDatabase as PyClassImpl>::BaseNativeType as PyClassBaseType>::Layout<RedisCacheDatabase>
type Layout = <<RedisCacheDatabase as PyClassImpl>::BaseNativeType as PyClassBaseType>::Layout<RedisCacheDatabase>
Source§type ThreadChecker = NoopThreadChecker
type ThreadChecker = NoopThreadChecker
type Inventory = Pyo3MethodsInventoryForRedisCacheDatabase
Source§type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild
type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild
Source§type BaseNativeType = PyAny
type BaseNativeType = PyAny
PyAny by default, and when you declare
#[pyclass(extends=PyDict)], it’s PyDict.fn items_iter() -> PyClassItemsIter
fn lazy_type_object() -> &'static LazyTypeObject<Self>
Source§fn dict_offset() -> Option<PyObjectOffset>
fn dict_offset() -> Option<PyObjectOffset>
Source§fn weaklist_offset() -> Option<PyObjectOffset>
fn weaklist_offset() -> Option<PyObjectOffset>
Source§impl PyClassNewTextSignature for RedisCacheDatabase
impl PyClassNewTextSignature for RedisCacheDatabase
const TEXT_SIGNATURE: &'static str = "(trader_id, instance_id, config_json)"
Source§impl PyTypeInfo for RedisCacheDatabase
impl PyTypeInfo for RedisCacheDatabase
Source§const NAME: &str = <Self as ::pyo3::PyClass>::NAME
const NAME: &str = <Self as ::pyo3::PyClass>::NAME
prefer using ::type_object(py).name() to get the correct runtime value
Source§const MODULE: Option<&str> = <Self as ::pyo3::impl_::pyclass::PyClassImpl>::MODULE
const MODULE: Option<&str> = <Self as ::pyo3::impl_::pyclass::PyClassImpl>::MODULE
prefer using ::type_object(py).module() to get the correct runtime value
Source§fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
Source§fn type_object(py: Python<'_>) -> Bound<'_, PyType>
fn type_object(py: Python<'_>) -> Bound<'_, PyType>
impl DerefToPyAny for RedisCacheDatabase
impl ExtractPyClassWithClone for RedisCacheDatabase
Auto Trait Implementations§
impl Freeze for RedisCacheDatabase
impl !RefUnwindSafe for RedisCacheDatabase
impl Send for RedisCacheDatabase
impl Sync for RedisCacheDatabase
impl Unpin for RedisCacheDatabase
impl UnsafeUnpin for RedisCacheDatabase
impl !UnwindSafe for RedisCacheDatabase
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<'py, T> IntoPyObjectExt<'py> for Twhere
T: IntoPyObject<'py>,
impl<'py, T> IntoPyObjectExt<'py> for Twhere
T: IntoPyObject<'py>,
Source§fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr>
fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr>
self into an owned Python object, dropping type information.Source§impl<'py, T> IntoPyObjectNautilusExt<'py> for Twhere
T: IntoPyObjectExt<'py>,
impl<'py, T> IntoPyObjectNautilusExt<'py> for Twhere
T: IntoPyObjectExt<'py>,
Source§impl<T> PyErrArguments for T
impl<T> PyErrArguments for T
Source§impl<T> PyTypeCheck for Twhere
T: PyTypeInfo,
impl<T> PyTypeCheck for Twhere
T: PyTypeInfo,
Source§const NAME: &'static str = T::NAME
const NAME: &'static str = T::NAME
Use ::classinfo_object() instead and format the type name at runtime. Note that using built-in cast features is often better than manual PyTypeCheck usage.