Document storage backend decoration as the way to customize storages
Author: janbucharCreated Sep 18, 2026Updated Sep 18, 2026
Labelst-tooling
- People try
class CryptedKeyValueStore extends KeyValueStore(encryption, LRU caching). In v4 it constructs, butcommitJournalEntriesre-enterssetValue, so an override runs twice inside a request handler, andvalues()/entries()bypass an overriddengetValue. Frontend subclassing is not something we want to support. - The simplified
StorageBackend/KeyValueStoreBackendcontract makes a decorating backend the right answer: ~40 lines, works with transactions, rollback,useState, streams viawithDirectStorageAccess, andgetStorageBackendCacheKey()keeps it apart from the wrapped backend in the instance cache. - Write it up in the result storage guide with encryption and a read cache as the examples. Optionally ship a delegating base (
DelegatingStorageBackend/DelegatingKeyValueStoreBackend) with pass-through defaults and a derived cache key, so a wrapper only overrides what it changes.
Source: apify/crawlee