Sha256: e8941b1a9013a762c53306efc658d5f8dae54aa50bfea76d5b4ede3b6b8ba92c

Contents?: true

Size: 1.15 KB

Versions: 2

Compression:

Stored size: 1.15 KB

Contents

require 'drb'

require 'glue/cache/memory'

module Glue

# A cached backed in a DRb server.
# 
# === Example
#
# This cache needs a corresponding DRb server. Here is how you
# can setup the standard Nitro Drb server to keep a DrbCache:
#
# require 'glue/cache/memory'
#
# class MyDrbServer < Nitro::DrbServer
#   def setup_drb_objects
#     ..
#     @my_cache = SyncHash.new 
#     DRb.start_service("druby://#{my_drb_address}:#{my_drb_port}", @my_cache)
#     ..
#   end
# end    
#
# MyDrbServer.start

class DrbCache < MemoryCache

  # Initialize the cache.
  #
  # === Options
  #
  # :address = The address of the DRb cache object.
  # :port = The port of the DRb cache object.
  
  # The address of the Session cache / store (if distibuted).
 
  setting :address, :default => '127.0.0.1', :doc => 'The address of the Session cache'
  
  # The port of the Session DRb cache / store (if distributed).
 
  setting :port, :default => 9069, :doc => 'The port of the Session cache'
  
  
  def initialize(address = DrbCache.address, port = DrbCache.port)
    @hash = DRbObject.new(nil, "druby://#{address}:#{port}") 
  end
  
end

end

# * George Moschovitis <gm@navel.gr>

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
glue-0.30.0 lib/glue/cache/drb.rb
glue-0.31.0 lib/glue/cache/drb.rb