Alpha Version: You are viewing the ALPHA documentation. This is an experimental version and may contain breaking changes.
Skip to main content

Counter — Local

Source: reventless-local/src/adapter/Counter/LocalCounterHandler.res

AWS equivalent: Counter → DynamoDB Streams

Data Structure

Counter values are stored in a module-level Dict<string, int>. A second Dict<string, bool> tracks which (counterId, targetRef) pairs have already been counted, providing deduplication.

Operations

OperationDescription
addToCounterTargetIncrements the counter for a given counterId by target, skipping if targetRef was already counted

Test Utilities

FunctionDescription
getCount(counterId)Returns the current count for a counter ID
reset()Clears all counters and deduplication state — call in beforeEach

Key Differences from AWS

AspectLocalAWS
StorageModule-level DictDynamoDB tables (references + counts)
DeduplicationIn-memory (counterId, targetRef) trackingDynamoDB conditional writes
TriggerDirect function callDynamoDB Streams
PersistenceNone — call reset() between testsDurable