Class: HLS::Storage::Memory
- Inherits:
-
Object
- Object
- HLS::Storage::Memory
- Defined in:
- lib/hls/storage.rb
Overview
In-memory bucket for tests. Backed by a hash protected by a single mutex — concurrent puts and gets across threads are safe.
Defined Under Namespace
Classes: Object, PutResponse, Response
Constant Summary collapse
- DEFAULT_SIGNING_TTL =
3600
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#signing_ttl ⇒ Object
Returns the value of attribute signing_ttl.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name:, signing_ttl: DEFAULT_SIGNING_TTL) ⇒ Memory
constructor
A new instance of Memory.
- #keys ⇒ Object
- #object(key) ⇒ Object
Constructor Details
#initialize(name:, signing_ttl: DEFAULT_SIGNING_TTL) ⇒ Memory
Returns a new instance of Memory.
80 81 82 83 84 85 |
# File 'lib/hls/storage.rb', line 80 def initialize(name:, signing_ttl: DEFAULT_SIGNING_TTL) @name = name @signing_ttl = signing_ttl @store = {} @mutex = Mutex.new end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
77 78 79 |
# File 'lib/hls/storage.rb', line 77 def name @name end |
#signing_ttl ⇒ Object
Returns the value of attribute signing_ttl.
78 79 80 |
# File 'lib/hls/storage.rb', line 78 def signing_ttl @signing_ttl end |
Class Method Details
.build(name: "memory", signing_ttl: DEFAULT_SIGNING_TTL, objects: {}) ⇒ Object
71 72 73 74 75 |
# File 'lib/hls/storage.rb', line 71 def self.build(name: "memory", signing_ttl: DEFAULT_SIGNING_TTL, objects: {}) bucket = new(name: name, signing_ttl: signing_ttl) objects.each { |key, body| bucket.object(key).put(body: body) } bucket end |