Created
August 13, 2011 16:02
-
-
Save durango/1143986 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 '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