Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ActionDispatch::Session::CacheStore as a generic way of storing sessions in a cache #3396

Merged
merged 1 commit into from Oct 22, 2011

Conversation

bdurand
Copy link
Contributor

@bdurand bdurand commented Oct 21, 2011

Here is a new storage engine for Rails session storage that stores sessions in the Rails.cache.

This analogous to MemCacheStore but it is far more flexible in that it can use any backend that is available for Rails.cache (i.e. DalliStore, RedisStore, etc.). It also doesn't require configuring your memcached cluster twice in your environment config file.

(Note: this was originally opened in Lighthouse at https://rails.lighthouseapp.com/projects/8994/tickets/6675)

@josevalim
Copy link
Contributor

I like this. /cc @jeremy @fxn

# not specified, <tt>Rails.cache</tt> will be used.
def initialize(app, options = {})
@cache = options[:cache] || Rails.cache
options[:expire_after] ||= @cache.options[:expires_in]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calling the option expire_after is ambiguous: can mean either a timestamp (after time T) as well as a duration (after N minutes).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

expire_after is what is already used internally... :( I am merging this!

@jeremy
Copy link
Member

jeremy commented Oct 22, 2011

Looks great. A subsequent patch could make the MemCacheStore wrap this, passing a :cache => ... option.

josevalim added a commit that referenced this pull request Oct 22, 2011
Add ActionDispatch::Session::CacheStore as a generic way of storing sessions in a cache
@josevalim josevalim merged commit 3c31299 into rails:master Oct 22, 2011
@josevalim
Copy link
Contributor

Thanks @bdurand for the latest pull requests! They were very well written, tested and updated the proper guides! We hope we will see more pull requests coming from you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants