Created
June 28, 2009 18:57
-
-
Save otype/137347 to your computer and use it in GitHub Desktop.
Memcached in Ruby
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 'rubygems' | |
require 'memcache' | |
class Memcaching | |
def initialize | |
@cache = MemCache.new 'localhost:11211', :namespace => 'goofingaroundwithmemcached' | |
end | |
def load_key_into_memcache(key,value) | |
@cache.set(key, value, 0) | |
end | |
def key_from_memcache(key) | |
@cache.get(key) | |
end | |
end | |
mc = Memcaching.new | |
key = "mykey" | |
value = "myvalue" | |
mc.load_key_into_memcache(key,value) | |
puts mc.key_from_memcache(key) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment