Class: Fluent::PluginHelper::Storage::PersistentWrapper
- Inherits:
-
Object
- Object
- Fluent::PluginHelper::Storage::PersistentWrapper
show all
- Extended by:
- Forwardable
- Defined in:
- lib/fluent/plugin_helper/storage.rb
Instance Method Summary
collapse
Constructor Details
Returns a new instance of PersistentWrapper.
198
199
200
201
|
# File 'lib/fluent/plugin_helper/storage.rb', line 198
def initialize(storage)
@storage = storage
@monitor = Monitor.new
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
207
208
209
|
# File 'lib/fluent/plugin_helper/storage.rb', line 207
def method_missing(name, *args)
@monitor.synchronize{ @storage.__send__(name, *args) }
end
|
Instance Method Details
#autosave ⇒ Object
219
220
221
|
# File 'lib/fluent/plugin_helper/storage.rb', line 219
def autosave
false
end
|
#delete(key) ⇒ Object
266
267
268
269
270
271
272
273
|
# File 'lib/fluent/plugin_helper/storage.rb', line 266
def delete(key)
@monitor.synchronize do
@storage.load
val = @storage.delete(key)
@storage.save
val
end
end
|
#fetch(key, defval) ⇒ Object
250
251
252
253
254
255
|
# File 'lib/fluent/plugin_helper/storage.rb', line 250
def fetch(key, defval)
@monitor.synchronize do
@storage.load
@storage.fetch(key, defval)
end
end
|
#get(key) ⇒ Object
243
244
245
246
247
248
|
# File 'lib/fluent/plugin_helper/storage.rb', line 243
def get(key)
@monitor.synchronize do
@storage.load
@storage.get(key)
end
end
|
#implementation ⇒ Object
227
228
229
|
# File 'lib/fluent/plugin_helper/storage.rb', line 227
def implementation
@storage
end
|
#load ⇒ Object
231
232
233
234
235
|
# File 'lib/fluent/plugin_helper/storage.rb', line 231
def load
@monitor.synchronize do
@storage.load
end
end
|
#persistent ⇒ Object
215
216
217
|
# File 'lib/fluent/plugin_helper/storage.rb', line 215
def persistent
true
end
|
#persistent_always? ⇒ Boolean
211
212
213
|
# File 'lib/fluent/plugin_helper/storage.rb', line 211
def persistent_always?
true
end
|
#put(key, value) ⇒ Object
257
258
259
260
261
262
263
264
|
# File 'lib/fluent/plugin_helper/storage.rb', line 257
def put(key, value)
@monitor.synchronize do
@storage.load
@storage.put(key, value)
@storage.save
value
end
end
|
#save ⇒ Object
237
238
239
240
241
|
# File 'lib/fluent/plugin_helper/storage.rb', line 237
def save
@monitor.synchronize do
@storage.save
end
end
|
#synchronized? ⇒ Boolean
223
224
225
|
# File 'lib/fluent/plugin_helper/storage.rb', line 223
def synchronized?
true
end
|
#update(key, &block) ⇒ Object
275
276
277
278
279
280
281
282
283
|
# File 'lib/fluent/plugin_helper/storage.rb', line 275
def update(key, &block)
@monitor.synchronize do
@storage.load
v = block.call(@storage.get(key))
@storage.put(key, v)
@storage.save
v
end
end
|