Permalink
Browse files

lets see

  • Loading branch information...
0 parents commit 0121e81beb85a485113c642aedd52eb5eb93bfa8 @pedro committed Mar 26, 2012
Showing with 38 additions and 0 deletions.
  1. +26 −0 lib/redis-store-rails2.rb
  2. +12 −0 redis-store-rails2.gemspec
@@ -0,0 +1,26 @@
+require "active_support"
+require "active_support/cache"
+
+class RedisStoreRails2 < ActiveSupport::Cache::Store
+ def initialize(address=nil)
+ address ||= "redis://localhost:6379"
+
+ uri = URI.parse(address)
+ options = { :host => uri.host, :port => uri.port }
+ password = uri.password || uri.user
+ options.merge!(:password => password) if password
+ @store = Redis.new(options)
+ end
+
+ def read(key, options = nil) # :nodoc:
+ super
+ @store.get(key)
+ end
+
+ def write(key, value, options={})
+ super
+ response = @store.set(key, value)
+ @store.expire(key, options[:expires_in]) if options[:expires_in]
+ response == "OK"
+ end
+end
@@ -0,0 +1,12 @@
+Gem::Specification.new do |s|
+ s.name = "redis-store-rails2"
+ s.version = "0.0.1"
+ s.authors = ["Pedro Belo"]
+ s.email = ["pedrobelo@gmail.com"]
+ s.summary = %q{Redis session store for Rails 2 apps}
+ s.description = %q{Redis session store for Rails 2 apps}
+
+ s.rubyforge_project = "redis-store-rails2"
+
+ s.require_paths = ["lib"]
+end

0 comments on commit 0121e81

Please sign in to comment.