Sha256: c884392a054e989eda9b9ab5a61daa6028648a487b2d8059e5ddc6a27f695150

Contents?: true

Size: 1020 Bytes

Versions: 3

Compression:

Stored size: 1020 Bytes

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
  
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
cachetastic-1.2.7.1 lib/adapters/cachetastic_adapters_drb.rb
cachetastic-1.3.0 lib/adapters/cachetastic_adapters_drb.rb
cachetastic-1.3.1 lib/adapters/cachetastic_adapters_drb.rb