Class: Innate::Cache::DRb
- Inherits:
-
Object
- Object
- Innate::Cache::DRb
- Includes:
- API
- Defined in:
- /home/manveru/github/ramaze/ramaze.net/tmp/git/innate/lib/innate/cache/drb.rb
Overview
Cache utilizing a DRb server.
You will need to run a corresponding DRb server to use this cache. The example below is using a normal Hash, but it is recommended to use a thread-safe alternative like SyncHash.
Please note that on some Ruby implementations, access to Hash is not atomic and you might need to lock around access to avoid race conditions.
Constant Summary
- OPTIONS =
{:address => '127.0.0.1', :port => 9069}
Instance Method Summary (collapse)
-
- (Object) cache_clear
-
- (Object) cache_delete(*args)
-
- (Object) cache_fetch(*args)
-
- (Object) cache_setup(*args)
-
- (Object) cache_store(*args)
Instance Method Details
- (Object) cache_clear
41 42 43 |
# File '/home/manveru/github/ramaze/ramaze.net/tmp/git/innate/lib/innate/cache/drb.rb', line 41 def cache_clear @store.clear end |
- (Object) cache_delete(*args)
53 54 55 |
# File '/home/manveru/github/ramaze/ramaze.net/tmp/git/innate/lib/innate/cache/drb.rb', line 53 def cache_delete(*args) super{|key| @store.delete(key) } end |
- (Object) cache_fetch(*args)
49 50 51 |
# File '/home/manveru/github/ramaze/ramaze.net/tmp/git/innate/lib/innate/cache/drb.rb', line 49 def cache_fetch(*args) super{|key| @store[key] } end |
- (Object) cache_setup(*args)
36 37 38 39 |
# File '/home/manveru/github/ramaze/ramaze.net/tmp/git/innate/lib/innate/cache/drb.rb', line 36 def cache_setup(*args) address, port = OPTIONS.values_at(:address, :port) @store = DRbObject.new(nil, "druby://#{address}:#{port}") end |
- (Object) cache_store(*args)
45 46 47 |
# File '/home/manveru/github/ramaze/ramaze.net/tmp/git/innate/lib/innate/cache/drb.rb', line 45 def cache_store(*args) super{|key, value| @store[key] = value } end |