Redrack::Session 1.0.0 and Redrails::Session 1.0.0

Hello, not sure what the convention(s)/requirement(s) are for posting
gem
release annoucements but I’m going to just hold my breath here and click
“send” anyway… (hope no one is too offended).

The redrack-session gem is a redis-based session store for rack
applications while redrails-session is a simple “glue” or wrapper gem to
make it super-simple to use redrack-session in your rails apps.

Like others who’ve created similar gems, this is pretty much a
“translation” of the Memcached session store that comes with the rack
gem
(Rack::Session::Memcached). This is a fresh, brand new gem and I’d love
to
get some feedback.

This gem requires a redis server, the redis gem (~> 2.2.2), and the
redis-namespace gem (~> 1.1.0). It’s a given that rack is required (~>
1.3.5). This gem is based on the latest 1.3.x version of rack and does
NOT
support the older 1.2.x version(s) of rack.

The redrails-session gem requires rails (~> 3.1.0) and the
redrack-session
gem (~> 1.0.0).

== redrack-session: https://github.com/zettabyte/redrack-session (gem
install redrack-session)
== redrails-session: https://github.com/zettabyte/redrails-session (gem
install redrails-session)

Example usage of redrack-session:

require ‘rack’
require ‘redrack-session’

class MyApp
def call(env)
session = env[“rack.session”]
session[“counter”] ||= 0
session[“counter”] += 1
[200, {“Content-Type” => “text/plain”}, [“Counter:
#{session[‘counter’]}”]]
end
end

Rack::Server.start(
:app => Redrack::Session::Middleware.new(MyApp.new),
:Port => 9292
)

Example usage of redrails-session:

Gemfile

source :rubygems
gem “rails”, “3.1.1”
gem “redrails-session”, “~> 1.0.0”

… other gems …

config/initializers/session_store.rb

require ‘redrails-store’
MyApp::Application.config.session_store :redrails_session_store

== Future Improvements

I plan to add clustering support to the redrack-session gem (using
Redis::HashRing?). I’d also like to make it so the redrails-session gem
can, by default, look for a ‘config/redrails-session.yml’ (or similar)
configuration file in a rails project in order to load
environment-specific
configuration settings. I may play with adding a railtie initializer to
redrails-session to support zero-configuration when using defaults,
obviating the need for ‘config/initializers/session_store.rb’.

Anyhow, I know there are already solutions out there but none quite met
the
demanding requirements of my personal OCD requirements. Plus, it’s been
a
fun learning opportunity. Hopefully others will find this useful too.