Class: Cachetastic::Adapters::Drb

Inherits:
Base show all
Defined in:
lib/gems/cachetastic-2.1.2/lib/cachetastic/adapters/drb.rb

Overview

This adapter uses Cachetastic::Drb::Server as it’s backing. The configuration for this should look something like this:

my_awesome_cache_options:
  debug: false
  adapter: drb
  store_options:
    host: druby://127.0.0.1:61676

Instance Attribute Summary collapse

Attributes inherited from Base

#logger, #name

Instance Method Summary collapse

Methods inherited from Base

#configuration, configuration, #debug?, #initialize

Constructor Details

This class inherits a constructor from Cachetastic::Adapters::Base

Instance Attribute Details

#drb_storeObject

Returns the value of attribute drb_store.



10
11
12
# File 'lib/gems/cachetastic-2.1.2/lib/cachetastic/adapters/drb.rb', line 10

def drb_store
  @drb_store
end

Instance Method Details

#delete(key, delay = 0) ⇒ Object



38
39
40
# File 'lib/gems/cachetastic-2.1.2/lib/cachetastic/adapters/drb.rb', line 38

def delete(key, delay = 0)
  self.drb_store.delete(self.name, key)
end

#expire_allObject



25
26
27
# File 'lib/gems/cachetastic-2.1.2/lib/cachetastic/adapters/drb.rb', line 25

def expire_all
  self.drb_store.expire_all(self.name)
end

#get(key) ⇒ Object

See Cachetastic::Adapters::Base



30
31
32
# File 'lib/gems/cachetastic-2.1.2/lib/cachetastic/adapters/drb.rb', line 30

def get(key)
  Cachetastic::Caches::Base.unmarshall(self.drb_store.get(self.name, key))
end

#set(key, value, expiry = 0) ⇒ Object



34
35
36
# File 'lib/gems/cachetastic-2.1.2/lib/cachetastic/adapters/drb.rb', line 34

def set(key, value, expiry = 0)
  self.drb_store.set(self.name, key, Cachetastic::Caches::Base.marshall(value), expiry)
end

#setupObject



20
21
22
23
# File 'lib/gems/cachetastic-2.1.2/lib/cachetastic/adapters/drb.rb', line 20

def setup
  # self.all_options["marshall_method"] = "ruby"
  self.drb_store = DRbObject.new_with_uri(configuration.servers)
end

#statsObject



42
43
44
45
46
47
48
49
# File 'lib/gems/cachetastic-2.1.2/lib/cachetastic/adapters/drb.rb', line 42

def stats
  super
  begin
    self.drb_store.stats if self.drb_store.respond_to? 'stats'
  rescue Exception => e
    puts "Calling stats on the DRb store raised this exception: #{e.message}"
  end
end

#valid?Boolean

Returns:

  • (Boolean)


12
13
14
15
16
17
18
# File 'lib/gems/cachetastic-2.1.2/lib/cachetastic/adapters/drb.rb', line 12

def valid?
  begin
    return self.drb_store.ping
  rescue Exception => e
    return false
  end
end