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.
172 173 174 |
# File 'lib/active_cipher_storage/multipart_upload.rb', line 172 def initialize @data = Concurrent::Map.new end |
Instance Method Details
#delete(id) ⇒ Object
187 |
# File 'lib/active_cipher_storage/multipart_upload.rb', line 187 def delete(id) = @data.delete(id) |
#read(id) ⇒ Object
176 177 178 179 180 181 |
# File 'lib/active_cipher_storage/multipart_upload.rb', line 176 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
183 184 185 |
# File 'lib/active_cipher_storage/multipart_upload.rb', line 183 def write(id, data, expires_in: nil) @data[id] = { data: data, expires_at: expires_in && Time.now.to_i + expires_in } end |