Sha256: 4a992cde839d3d763133b60f92cd45fc3fd6e36b432f94a6947c1fdc0356c3a7

Contents?: true

Size: 1.21 KB

Versions: 9

Compression:

Stored size: 1.21 KB

Contents

# 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
class Cachetastic::Adapters::Drb < Cachetastic::Adapters::Base
  
  attr_accessor :drb_store
  
  def valid?
    begin
      return self.drb_store.ping
    rescue Exception => e
      return false
    end
  end

  def setup
    self.all_options["marshall_method"] = "ruby"
    self.drb_store = DRbObject.new_with_uri(self.store_options["host"])
  end
  
  def expire_all
    self.drb_store.expire_all(self.name)
  end
  
  # See Cachetastic::Adapters::Base
  def get(key)
    Cachetastic::Caches::Base.unmarshall(self.drb_store.get(self.name, key))
  end
  
  def set(key, value, expiry = 0)
    self.drb_store.set(self.name, key, Cachetastic::Caches::Base.marshall(value), expiry)
  end
  
  def delete(key, delay = 0)
    self.drb_store.delete(self.name, key)
  end
  
  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
  
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
cachetastic-1.4.1 lib/adapters/cachetastic_adapters_drb.rb
cachetastic-1.4.2 lib/adapters/cachetastic_adapters_drb.rb
cachetastic-1.6.0 lib/adapters/cachetastic_adapters_drb.rb
cachetastic-1.7.0 lib/adapters/cachetastic_adapters_drb.rb
cachetastic-1.7.3 lib/adapters/cachetastic_adapters_drb.rb
cachetastic-1.7.4 lib/adapters/cachetastic_adapters_drb.rb
cachetastic-1.7.2 lib/adapters/cachetastic_adapters_drb.rb
cachetastic-1.4.0 lib/adapters/cachetastic_adapters_drb.rb
cachetastic-1.5.0 lib/adapters/cachetastic_adapters_drb.rb