/usr/lib/ruby/1.8/innate/cache/drb.rb is in libinnate-ruby1.8 2010.07-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | require 'drb'
module Innate
class Cache
# 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.
#
# @example usage of DRb server
# require 'drb'
#
# URI = "druby://127.0.0.1:9069"
# CACHE = {}
#
# $SAFE = 1 # disable eval and friends
#
# DRb.start_service(URI, CACHE)
# DRb.thread.join
#
# 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.
#
# @example for all caches
# Innate.options.cache.default = Innate::Cache::DRb
#
# @example for sessions only
# Innate.options.cache.session = Innate::Cache::DRb
class DRb
include Cache::API
OPTIONS = {:address => '127.0.0.1', :port => 9069}
def cache_setup(*args)
address, port = OPTIONS.values_at(:address, :port)
@store = DRbObject.new(nil, "druby://#{address}:#{port}")
end
def cache_clear
@store.clear
end
def cache_store(*args)
super{|key, value| @store[key] = value }
end
def cache_fetch(*args)
super{|key| @store[key] }
end
def cache_delete(*args)
super{|key| @store.delete(key) }
end
end
end
end
|