AwsEncryptionSdk.Cache.CacheEntry (AWS Encryption SDK v0.7.0)
View SourceCache entry containing cryptographic materials with usage metadata.
Fields
:materials- EncryptionMaterials or DecryptionMaterials:creation_time- Monotonic time when entry was created (seconds):expiry_time- Monotonic time when entry expires (seconds):messages_used- Number of messages encrypted with this entry:bytes_used- Number of bytes encrypted with this entry
Summary
Functions
Checks if the cache entry has exceeded usage limits.
Checks if the cache entry has expired.
Creates a new cache entry with the given materials and TTL.
Types
@type materials() :: AwsEncryptionSdk.Materials.EncryptionMaterials.t() | AwsEncryptionSdk.Materials.DecryptionMaterials.t()
@type t() :: %AwsEncryptionSdk.Cache.CacheEntry{ bytes_used: non_neg_integer(), creation_time: integer(), expiry_time: integer(), materials: materials(), messages_used: non_neg_integer() }
Functions
@spec exceeded_limits?(t(), non_neg_integer(), non_neg_integer()) :: boolean()
Checks if the cache entry has exceeded usage limits.
Parameters
entry- The cache entrymax_messages- Maximum messages allowedmax_bytes- Maximum bytes allowed
Examples
iex> alias AwsEncryptionSdk.Cache.CacheEntry
iex> alias AwsEncryptionSdk.Materials.EncryptionMaterials
iex> alias AwsEncryptionSdk.AlgorithmSuite
iex> suite = AlgorithmSuite.aes_256_gcm_hkdf_sha512_commit_key()
iex> materials = EncryptionMaterials.new_for_encrypt(suite, %{})
iex> entry = %CacheEntry{
...> materials: materials,
...> creation_time: 0,
...> expiry_time: 1000,
...> messages_used: 100,
...> bytes_used: 1000
...> }
iex> CacheEntry.exceeded_limits?(entry, 50, 10000)
true
Checks if the cache entry has expired.
Examples
iex> alias AwsEncryptionSdk.Cache.CacheEntry
iex> alias AwsEncryptionSdk.Materials.EncryptionMaterials
iex> alias AwsEncryptionSdk.AlgorithmSuite
iex> suite = AlgorithmSuite.aes_256_gcm_hkdf_sha512_commit_key()
iex> materials = EncryptionMaterials.new_for_encrypt(suite, %{})
iex> entry = CacheEntry.new(materials, 300)
iex> CacheEntry.expired?(entry)
false
@spec new(materials(), pos_integer()) :: t()
Creates a new cache entry with the given materials and TTL.
Parameters
materials- EncryptionMaterials or DecryptionMaterialsmax_age- TTL in seconds
Examples
iex> alias AwsEncryptionSdk.Cache.CacheEntry
iex> alias AwsEncryptionSdk.Materials.EncryptionMaterials
iex> alias AwsEncryptionSdk.AlgorithmSuite
iex> suite = AlgorithmSuite.aes_256_gcm_hkdf_sha512_commit_key()
iex> materials = EncryptionMaterials.new_for_encrypt(suite, %{})
iex> entry = CacheEntry.new(materials, 300)
iex> entry.messages_used
0