Class: ActiveCipherStorage::EncryptedMultipartUpload::MemorySessionStore
- Inherits:
-
Object
- Object
- ActiveCipherStorage::EncryptedMultipartUpload::MemorySessionStore
- Defined in:
- lib/active_cipher_storage/multipart_upload.rb
Overview
Thread-safe in-memory session store backed by Concurrent::Map. Replace with a Rails.cache wrapper for multi-process deployments.
Instance Method Summary collapse
- #delete(id) ⇒ Object
-
#initialize ⇒ MemorySessionStore
constructor
A new instance of MemorySessionStore.
- #read(id) ⇒ Object
- #write(id, data, expires_in: nil) ⇒ Object
Constructor Details
#initialize ⇒ MemorySessionStore
Returns a new instance of MemorySessionStore.
181 182 183 |
# File 'lib/active_cipher_storage/multipart_upload.rb', line 181 def initialize @data = Concurrent::Map.new end |
Instance Method Details
#delete(id) ⇒ Object
196 |
# File 'lib/active_cipher_storage/multipart_upload.rb', line 196 def delete(id) = @data.delete(id) |
#read(id) ⇒ Object
185 186 187 188 189 190 |
# File 'lib/active_cipher_storage/multipart_upload.rb', line 185 def read(id) entry = @data[id] return nil unless entry return nil if entry[:expires_at] && Time.now.to_i > entry[:expires_at] entry[:data] end |
#write(id, data, expires_in: nil) ⇒ Object
192 193 194 |
# File 'lib/active_cipher_storage/multipart_upload.rb', line 192 def write(id, data, expires_in: nil) @data[id] = { data: data, expires_at: expires_in && Time.now.to_i + expires_in } end |