Skip to content

Instantly share code, notes, and snippets.

@durango
Created August 13, 2011 16:02
Show Gist options
  • Save durango/1143986 to your computer and use it in GitHub Desktop.
Save durango/1143986 to your computer and use it in GitHub Desktop.
require 'redis'
# Easily use Redis anywhere from controllers, views, and more importantly models.
class RedisCache
def initialize
@redis = Redis.new(:host => "127.0.0.1", :port => 15501, :password => "password", :db => 1)
end
def method_missing(id, *args, &block)
@redis.send(id, *args, &block)
end
end
# Initialize it
Cache = RedisCache.new
# To call it from anywhere...
::Cache.get("get_the_key")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment