Class: ActiveSupport::Cache::DynamoStore
- Inherits:
-
Store
- Object
- Store
- ActiveSupport::Cache::DynamoStore
- Defined in:
- lib/active_support/cache/dynamo_store.rb
Constant Summary collapse
- DEFAULT_HASH_KEY =
'CacheKey'
- DEFAULT_TTL_KEY =
'TTL'
- CONTENT_KEY =
'b_item_value'
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#dynamodb_client ⇒ Object
readonly
Returns the value of attribute dynamodb_client.
-
#hash_key ⇒ Object
readonly
Returns the value of attribute hash_key.
-
#table_name ⇒ Object
readonly
Returns the value of attribute table_name.
-
#ttl_key ⇒ Object
readonly
Returns the value of attribute ttl_key.
Instance Method Summary collapse
-
#initialize(table_name:, dynamo_client: nil, hash_key: DEFAULT_HASH_KEY, ttl_key: DEFAULT_TTL_KEY, **opts) ⇒ DynamoStore
constructor
Instantiate the store.
Constructor Details
#initialize(table_name:, dynamo_client: nil, hash_key: DEFAULT_HASH_KEY, ttl_key: DEFAULT_TTL_KEY, **opts) ⇒ DynamoStore
Instantiate the store.
Example:
ActiveSupport::Cache::Dynamo.new(table_name: 'CacheTable')
=> hash_key: 'CacheKey', ttl_key: 'TTL', table_name: 'CacheTable'
ActiveSupport::Cache::Dynamo.new(
table_name: 'CacheTable',
dynamo_client: client,
hash_key: 'name',
ttl_key: 'key_ttl'
)
35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/active_support/cache/dynamo_store.rb', line 35 def initialize( table_name:, dynamo_client: nil, hash_key: DEFAULT_HASH_KEY, ttl_key: DEFAULT_TTL_KEY, **opts ) super(opts) @table_name = table_name @dynamodb_client = dynamo_client || Aws::DynamoDB::Client.new @ttl_key = ttl_key @hash_key = hash_key end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
20 21 22 |
# File 'lib/active_support/cache/dynamo_store.rb', line 20 def data @data end |
#dynamodb_client ⇒ Object (readonly)
Returns the value of attribute dynamodb_client.
20 21 22 |
# File 'lib/active_support/cache/dynamo_store.rb', line 20 def dynamodb_client @dynamodb_client end |
#hash_key ⇒ Object (readonly)
Returns the value of attribute hash_key.
20 21 22 |
# File 'lib/active_support/cache/dynamo_store.rb', line 20 def hash_key @hash_key end |
#table_name ⇒ Object (readonly)
Returns the value of attribute table_name.
20 21 22 |
# File 'lib/active_support/cache/dynamo_store.rb', line 20 def table_name @table_name end |
#ttl_key ⇒ Object (readonly)
Returns the value of attribute ttl_key.
20 21 22 |
# File 'lib/active_support/cache/dynamo_store.rb', line 20 def ttl_key @ttl_key end |