Skip to content

Commit 4618999

Browse files
author
David Massad
committed
Merge pull request aws#13: Add expire_at attribute you can configure TTL on for garbage collection.
1 parent 19e175c commit 4618999

File tree

1 file changed

+13
-2
lines changed
  • lib/aws/session_store/dynamo_db/locking

1 file changed

+13
-2
lines changed

lib/aws/session_store/dynamo_db/locking/base.rb

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ def table_opts(sid)
109109
def attr_updts(env, session, add_attrs = {})
110110
data = data_unchanged?(env, session) ? {} : data_attr(session)
111111
{
112-
:attribute_updates => merge_all(updated_attr, data, add_attrs),
113-
:return_values => "UPDATED_NEW"
112+
attribute_updates: merge_all(updated_attr, data, add_attrs, expire_attr),
113+
return_values: 'UPDATED_NEW'
114114
}
115115
end
116116

@@ -124,6 +124,17 @@ def created_attr
124124
{ "created_at" => updated_at }
125125
end
126126

127+
# Update client with current time + max_stale.
128+
def expire_at
129+
max_stale = @config.max_stale || 0
130+
{ value: (Time.now + max_stale).to_i, action: 'PUT' }
131+
end
132+
133+
# Attribute for TTL expiration of session.
134+
def expire_attr
135+
{ 'expire_at' => expire_at }
136+
end
137+
127138
# Attribute for updating session.
128139
def updated_attr
129140
{

0 commit comments

Comments
 (0)