LemonCore. Idempotency
(lemon_core v0.1.0)
View Source
Idempotency service for deduplicating operations.
This module provides a mechanism to ensure operations like send, agent,
and node.invoke are executed at-most-once by tracking operation keys.
Storage
Backed by LemonCore.IdempotencyStore.
Values include {result, inserted_at_ms}.
Examples
# Check for existing result
case LemonCore.Idempotency.get("messages", "msg_abc123") do
{:ok, result} ->
# Return cached result
result
:miss ->
# Execute operation and store result
result = execute_operation()
LemonCore.Idempotency.put("messages", "msg_abc123", result)
result
end
Summary
Functions
Delete an idempotency entry.
Execute a function with idempotency guarantees.
Get a cached result for a scope and key.
Store a result for a scope and key.
Store a result only if the key doesn't already exist.
Types
Functions
Delete an idempotency entry.
Execute a function with idempotency guarantees.
If the key exists, returns the cached result. Otherwise, executes the function, caches the result, and returns it.
Get a cached result for a scope and key.
Returns {:ok, result} if found, or :miss if not found.
Store a result for a scope and key.
Always overwrites any existing value.
Store a result only if the key doesn't already exist.
Returns :ok if stored, or :exists if the key already exists.