Class: Fluent::PluginHelper::Storage::SynchronizeWrapper
- Inherits:
-
Object
- Object
- Fluent::PluginHelper::Storage::SynchronizeWrapper
- Extended by:
- Forwardable
- Defined in:
- lib/fluent/plugin_helper/storage.rb
Instance Method Summary collapse
- #delete(key) ⇒ Object
- #fetch(key, defval) ⇒ Object
- #get(key) ⇒ Object
- #implementation ⇒ Object
-
#initialize(storage) ⇒ SynchronizeWrapper
constructor
A new instance of SynchronizeWrapper.
- #load ⇒ Object
- #put(key, value) ⇒ Object
- #save ⇒ Object
- #synchronized? ⇒ Boolean
- #update(key, &block) ⇒ Object
Constructor Details
#initialize(storage) ⇒ SynchronizeWrapper
Returns a new instance of SynchronizeWrapper.
275 276 277 278 |
# File 'lib/fluent/plugin_helper/storage.rb', line 275 def initialize(storage) @storage = storage @mutex = Mutex.new end |
Instance Method Details
#delete(key) ⇒ Object
317 318 319 |
# File 'lib/fluent/plugin_helper/storage.rb', line 317 def delete(key) @mutex.synchronize{ @storage.delete(key) } end |
#fetch(key, defval) ⇒ Object
309 310 311 |
# File 'lib/fluent/plugin_helper/storage.rb', line 309 def fetch(key, defval) @mutex.synchronize{ @storage.fetch(key, defval) } end |
#get(key) ⇒ Object
305 306 307 |
# File 'lib/fluent/plugin_helper/storage.rb', line 305 def get(key) @mutex.synchronize{ @storage.get(key) } end |
#implementation ⇒ Object
289 290 291 |
# File 'lib/fluent/plugin_helper/storage.rb', line 289 def implementation @storage end |
#load ⇒ Object
293 294 295 296 297 |
# File 'lib/fluent/plugin_helper/storage.rb', line 293 def load @mutex.synchronize do @storage.load end end |
#put(key, value) ⇒ Object
313 314 315 |
# File 'lib/fluent/plugin_helper/storage.rb', line 313 def put(key, value) @mutex.synchronize{ @storage.put(key, value) } end |
#save ⇒ Object
299 300 301 302 303 |
# File 'lib/fluent/plugin_helper/storage.rb', line 299 def save @mutex.synchronize do @storage.save end end |
#synchronized? ⇒ Boolean
285 286 287 |
# File 'lib/fluent/plugin_helper/storage.rb', line 285 def synchronized? true end |
#update(key, &block) ⇒ Object
321 322 323 324 325 326 327 |
# File 'lib/fluent/plugin_helper/storage.rb', line 321 def update(key, &block) @mutex.synchronize do v = block.call(@storage.get(key)) @storage.put(key, v) v end end |