/usr/lib/ruby/vendor_ruby/rack/cache/appengine.rb is in ruby-rack-cache 1.2-4.
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 | require 'base64'
module Rack::Cache::AppEngine
module MC
require 'java'
import com.google.appengine.api.memcache.Expiration;
import com.google.appengine.api.memcache.MemcacheService;
import com.google.appengine.api.memcache.MemcacheServiceFactory;
import com.google.appengine.api.memcache.Stats;
Service = MemcacheServiceFactory.getMemcacheService
end unless defined?(Rack::Cache::AppEngine::MC)
class MemCache
def initialize(options = {})
@cache = MC::Service
@cache.namespace = options[:namespace] if options[:namespace]
end
def contains?(key)
MC::Service.contains(key)
end
def get(key)
value = MC::Service.get(key)
Marshal.load(Base64.decode64(value)) if value
end
def put(key, value, ttl = nil)
expiration = ttl ? MC::Expiration.byDeltaSeconds(ttl) : nil
value = Base64.encode64(Marshal.dump(value)).gsub(/\n/, '')
MC::Service.put(key, value, expiration)
end
def namespace
MC::Service.getNamespace
end
def namespace=(value)
MC::Service.setNamespace(value.to_s)
end
def delete(key)
MC::Service.delete(key)
end
end
end
|