Class: ActiveSupport::Cache::DynamoStore

Inherits:
Store
  • Object
show all
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

Instance Method Summary collapse

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

#dataObject (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_clientObject (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_keyObject (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_nameObject (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_keyObject (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