Created
March 6, 2012 21:42
-
-
Save LeifWarner/1989116 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'jruby-spymemcached' | |
class SpymemcachedWrapper | |
# Shamelessly cribbed from | |
# https://github.com/ikai/jruby-memcache-client/blob/master/lib/memcache.rb | |
def initialize(servers, opts) | |
@spymemcached = Spymemcached.new(servers) | |
at_exit { @spymemcached.shutdown } | |
@namespace = opts[:namespace] || opts["namespace"] | |
end | |
def get(key) | |
@spymemcached.get(make_cache_key(key)) | |
end | |
def set(key, value, expiry = 0) | |
@spymemcached.set(make_cache_key(key), value, expiry) | |
end | |
protected | |
def make_cache_key(key) | |
if @namespace.nil? then | |
key | |
else | |
"#{@namespace}:#{key}" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment