aws_encryption_sdk.caches.local

Local, in-memory, LRU, cryptographic materials cache for use with caching cryptographic materials providers.

Classes

LocalCryptoMaterialsCache(capacity) Local, in-memory, LRU, cache for use with caching cryptographic materials providers.
class aws_encryption_sdk.caches.local.LocalCryptoMaterialsCache(capacity)

Bases: aws_encryption_sdk.caches.base.CryptoMaterialsCache

Local, in-memory, LRU, cache for use with caching cryptographic materials providers.

New in version 1.3.0.

Parameters:capacity (int) – Maximum number of entries to retain in cache at once
clear()

Clears the cache.

get_decryption_materials(cache_key)

Locates exactly one available decryption materials cache entry for the specified cache_key.

Parameters:cache_key (bytes) – Cache ID for which to locate cache entries
Return type:aws_encryption_sdk.caches.CryptoMaterialsCacheEntry
Raises:CacheKeyError – if no values found in cache for cache_key
get_encryption_materials(cache_key, plaintext_length)

Locates exactly one available encryption materials cache entry for the specified cache_key, incrementing the entry’s usage stats prior to returning it to the caller.

Parameters:
  • cache_key (bytes) – Cache ID for which to locate cache entries
  • plaintext_length (int) – Length of plaintext associated with this request to the cache
Return type:

aws_encryption_sdk.caches.CryptoMaterialsCacheEntry

Raises:

CacheKeyError – if no values found in cache for cache_key

put_decryption_materials(cache_key, decryption_materials)

Adds decryption materials to the cache

Parameters:
Return type:

aws_encryption_sdk.caches.CryptoMaterialsCacheEntry

put_encryption_materials(cache_key, encryption_materials, plaintext_length, entry_hints=None)

Adds encryption materials to the cache.

Parameters:
  • cache_key (bytes) – Identifier for entries in cache
  • encryption_materials (aws_encryption_sdk.materials_managers.EncryptionMaterials) – Encryption materials to add to cache
  • plaintext_length (int) – Length of plaintext associated with this request to the cache
  • entry_hints (aws_encryption_sdk.caches.CryptoCacheEntryHints) – Metadata to associate with entry (optional)
Return type:

aws_encryption_sdk.caches.CryptoMaterialsCacheEntry

remove(value)

Removes a value from the cache.

Parameters:value (aws_encryption_sdk.caches.CryptoMaterialsCacheEntry) – Value to add to cache
Raises:CacheKeyError – if value not found in cache