Documentation Index
Fetch the complete documentation index at: https://mintlify.com/backtest-kit/backtest-kit-minio-s3-docker/llms.txt
Use this file to discover all available pages before exploring further.
BaseMap is a di-factory class that provides a namespaced, optionally TTL-bound key/value store backed by Redis. It is used directly by the three connection services — LogConnectionService, NotificationConnectionService, and StorageConnectionService — which extend it to add the time-ordered register / listNewest index on top of the base key/value primitives. Unlike BaseStorage (which targets durable, persistent S3 objects), BaseMap targets Redis and is optimised for fast writes, expiry-based cleanup, and cursor-based iteration over a namespaced keyspace.
Constructor
connectionKey is the namespace for all Redis keys managed by this instance. Every key written by BaseMap is stored in Redis as ${connectionKey}:${key} — the colon separator is added by the internal _getItemKey helper. Choose a unique connectionKey per logical store (e.g. "log-items-connection") to prevent key collisions between different services sharing the same Redis database.
ttlExpireSeconds defaults to DEFAULT_TTL_EXPIRE_SECONDS = 5 * 60 (300 seconds / 5 minutes). Pass -1 to disable expiry entirely, which is what all three connection services do — their time-ordered index entries are permanent until explicitly cleared.
TTL behaviour
ttlExpireSeconds is any positive integer, set() calls redis.expire(itemKey, ttlExpireSeconds) immediately after the redis.set(...) call, so each key automatically expires that many seconds after its last write. If the same key is written again before expiry, the TTL is reset.
All three connection services (
LogConnectionService, NotificationConnectionService, StorageConnectionService) construct their BaseMap with ttlExpireSeconds = -1. This makes their index entries permanent — they survive Redis restarts (if persistence is configured) and are never evicted by TTL. The -1 sentinel skips the redis.expire call entirely._getItemKey()
_ by convention) so that subclasses and tests can inspect or override key construction without duplicating the prefix logic.
Methods
Writes
value to Redis under the namespaced key. If ttlExpireSeconds !== -1, a TTL is applied immediately after the write. Throws if key is an empty string.Retrieves the value stored at the namespaced key. Returns
null if key is null or if the key does not exist in Redis (ioredis returns null for missing keys).Removes the namespaced key from Redis using
DEL. No-ops if key is null.Checks whether the namespaced key exists using Redis
EXISTS. Returns true only when EXISTS returns 1. Returns false for null keys.Deletes all keys matching
${connectionKey}:* using a SCAN loop. Iterates the keyspace in batches of ITERATOR_BATCH_SIZE = 100 and issues a DEL for each non-empty batch until the cursor returns to 0.Collects all key/value pairs matching
${connectionKey}:* into an in-memory array. Uses SCAN + MGET per batch to minimize round-trips. The connectionKey: prefix is stripped from returned keys so callers see logical keys only.Async generator that yields
[key, value] tuples via SCAN + MGET batches. The generator holds the SCAN cursor state across yields so it does not need to complete the full scan before returning the first result. Logical keys are returned with the connectionKey: prefix stripped.Async generator that yields logical key strings (prefix stripped) via SCAN batches. Does not fetch values, making it cheaper than
iterate() when only key enumeration is needed.Async generator that yields raw Redis string values via SCAN +
MGET batches. Skips entries whose value is not a string (null values from MGET are filtered out).Counts all keys matching
${connectionKey}:* by exhausting a SCAN loop and summing the lengths of each batch. No values are fetched.ITERATOR_BATCH_SIZE
clear, toArray, iterate, keys, values, size) pass COUNT 100 to the Redis SCAN command. This is a hint to Redis about how many keys to return per cursor step — Redis may return fewer or slightly more. A batch size of 100 balances the number of round-trips against the size of each response; increase it if you observe slow iteration over very large keyspaces and your Redis instance has headroom.