Today I fell in love with the
alias
method :)require 'memcached'
cache = Memcached.new "localhost:11211"
cache.set "message", "Hello, world!"
puts cache.get "message"
All is nice up to the get
and set
methods. Wouldn't it be nice to use the cache["message"]
syntax?class Memcached
alias :"[]" :get
alias :"[]=" :set
end
And then:cache["message"] = "Hello"
puts cache["message"]
And live is good again :)
1 comment:
Strange... Those aliases are there by default in Memcached::Rails... Why not in Memcached???
Post a Comment