Cache
Titancore provides one application cache repository backed exclusively by Redis. The repository keeps keys in its configured namespace, serializes JSON values and bytes, and delegates connection and atomic counter behavior to redis-py.
Register the cache service provider with an application before startup:
from titancore import Application
from titancore.cache import CacheServiceProvider
from titancore.facades import Cache
application = Application()
application.register(CacheServiceProvider("redis://localhost:6379/0"))
async with application:
await Cache.put("answer", 42, ttl=60)
assert await Cache.get("answer") == 42
The provider owns the repository lifecycle. Memory and workflow checkpoint
adapters can depend on the CacheRepository contract without importing Redis
client types. PostgreSQL remains the only supported database boundary; cache
storage is not a database fallback.
Concurrent misses in remember may each run the callback. The last completed
write determines the stored value. pull reads and removes a value in one
Redis operation.
Titancore escapes colons and percent signs in Redis namespaces. When upgrading from an earlier development version, existing entries under prefixes containing those characters become cold misses. The previous keys keep their existing expirations. Entries stored without an expiration remain under their old keys.
Register CacheServiceProvider() to read cache.url and cache.prefix from
the application configuration. The defaults are redis://localhost:6379/0
and titancore:cache. Explicit constructor arguments remain supported.