Documentation Index
Fetch the complete documentation index at: https://mintlify.com/theonetrade/backtest-monorepo-parallel/llms.txt
Use this file to discover all available pages before exploring further.
BaseMap is exported from packages/core/src/lib/common/BaseMap.ts and wraps a shared ioredis client with a namespace prefix and an optional TTL. It uses di-factory’s factory() helper to produce a mixin class, giving you a full key-value store scoped to a specific connectionKey prefix — all Redis keys are stored as <connectionKey>:<key>. Every method is async and internally uses SCAN-based iteration to remain safe on large keyspaces.
Constructor
BaseMap by calling it as a function:
Namespace prefix for all keys stored by this map. Every key is saved to Redis as
<connectionKey>:<key>, so different BaseMap subclasses never collide even when sharing the same Redis instance.How long (in seconds) each key lives before Redis expires it automatically. Defaults to
300 (5 minutes). Pass -1 to disable expiry entirely — keys will persist until explicitly deleted.Methods
set()
value in Redis at <connectionKey>:<key>. If ttlExpireSeconds is not -1, the key’s TTL is refreshed on every write.
The local key (without the namespace prefix). Throws
Error: Key cannot be empty if blank.The value to store. Serialised by
ioredis (strings are stored as-is; other types are coerced via toString()).get()
null if the key is null or does not exist in Redis.
The local key to look up. Passing
null is a safe no-op that returns null immediately.delete()
<connectionKey>:<key> from Redis. No-ops silently if the key does not exist.
The local key to remove.
has()
true if <connectionKey>:<key> exists in Redis, false otherwise. Uses the Redis EXISTS command.
The local key to check.
clear()
<connectionKey>:* using repeated SCAN + DEL batches of ITERATOR_BATCH_SIZE (100 keys per batch). This approach is non-blocking and safe on large keyspaces — it never runs a full KEYS scan that would stall the Redis event loop.
toArray()
connectionKey prefix.
Returns an array of [localKey, value] tuples.
iterate()
[localKey, value] pairs in the namespace, using SCAN batches of 100. Memory-efficient for large keyspaces.
keys()
iterate().
values()
keys().
size()
DBSIZE — the count is scoped to <connectionKey>:* only.
Returns number — the count of keys currently stored under this namespace.
TBaseMap
When you need to accept anyBaseMap subclass as a function parameter, use the utility type:
TBaseMap is defined as:
BaseMap factory, giving you full method-level typing without coupling to a specific subclass.
The underlying Redis client is obtained from
getRedis() imported from @backtest-kit/mongo. This is the same shared ioredis client used throughout the monorepo, so all BaseMap subclasses operate on the same Redis connection pool.