AwsEncryptionSdk.Cache.CryptographicMaterialsCache behaviour (AWS Encryption SDK v0.7.0)
View SourceBehaviour for Cryptographic Materials Cache implementations.
The CMC provides a caching layer for cryptographic materials, allowing the Caching CMM to reuse data keys across multiple encryption operations.
Spec Reference
Summary
Callbacks
Removes a cache entry.
Retrieves a cache entry.
Stores a cache entry.
Updates usage statistics for a cache entry.
Types
Callbacks
Removes a cache entry.
This operation MUST succeed even if no entry exists for the cache ID.
Parameters
cache- Cache implementationcache_id- 48-byte cache identifier
@callback get_cache_entry(cache(), cache_id()) :: {:ok, AwsEncryptionSdk.Cache.CacheEntry.t()} | {:error, :cache_miss}
Retrieves a cache entry.
Returns {:ok, entry} if found and not expired, {:error, :cache_miss} otherwise.
Expired entries MUST NOT be returned and SHOULD be removed.
Parameters
cache- Cache implementationcache_id- 48-byte cache identifier
@callback put_cache_entry(cache(), cache_id(), AwsEncryptionSdk.Cache.CacheEntry.t()) :: :ok
Stores a cache entry.
If an entry with the given cache ID already exists, it MUST be replaced. This operation MUST NOT return the inserted entry.
Parameters
cache- Cache implementationcache_id- 48-byte cache identifierentry- Cache entry to store
@callback update_usage(cache(), cache_id(), pos_integer(), non_neg_integer()) :: :ok | {:error, :cache_miss}
Updates usage statistics for a cache entry.
Increments messages_used and bytes_used counters atomically.
Returns {:error, :cache_miss} if entry doesn't exist.
Parameters
cache- Cache implementationcache_id- 48-byte cache identifiermessages- Number of messages to addbytes- Number of bytes to add