How does cache get refresh? #1575
-
Dear maintainers, As these are not described in docs, and I'm wandering how cache for a single trader get refreshed? Thanks in advance. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
I also see there is flush_db in cache, does that mean I can wire a db (redis or mongo) behind the cache system? |
Beta Was this translation helpful? Give feedback.
-
Hey @VeraLyu The cache is rather simple, for each data type there is just a deque per instrument (or bar type for bars) - with a default length of 10_000 (configurable). When you make a request for historical ticks (or bars), the deque is replaced by them on arrival, otherwise as each tick (or bar) hits the I think for a simple use case where you just want to maintain a hot cache of the most recent data, then what's built in will work for you. Notably though, the data is not persisted in the cache (generally only execution data is persisted, as well as currencies and instruments). To complicate the matter there is a message bus which can be backed by Redis - which will write any publishable message to a Redis stream, acting as a makeshift durable message broker. This can be autotrimmed to a specific lookback window, there's some write up on this in the docs. https://docs.nautilustrader.io/concepts/message_bus.html I hope that helps! |
Beta Was this translation helpful? Give feedback.
Hey @VeraLyu
The cache is rather simple, for each data type there is just a deque per instrument (or bar type for bars) - with a default length of 10_000 (configurable).
When you make a request for historical ticks (or bars), the deque is replaced by them on arrival, otherwise as each tick (or bar) hits the
DataEngine
the tick is added to theCache
, which appends to the left side of the queue, and will eventually fall off the right end as more are added.I think for a simple use case where you just want to maintain a hot cache of the most recent data, then what's built in will work for you. Notably though, the data is not persisted in the cache (generally only execution data is persisted,…