cookpad/session_store_relocator

Name: session_store_relocator

Owner: Cookpad Inc.

Description: Supports Rails session store relocation with duplicate write session data to multiple stores

Created: 2016-03-23 04:16:46.0

Updated: 2018-05-19 14:24:16.0

Pushed: 2016-03-23 04:56:13.0

Homepage: null

Size: 28

Language: Ruby

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

SessionStoreRelocator

Supports Rails session store relocation with duplicate write session data to multiple stores

Currently supports from Rails default ActionDispatch::Session::CookieStore to RedisSessionStore.

Installation

Add this line to your application's Gemfile:

'session_store_relocator'

And then execute:

$ bundle
Usage

This gem helps relocating session store by write data to both stores. After some weeks runnning with this gem, you switch session store to new one.

Step1. Write session store to both current (cookie) store and new (redis) store

Edit config/initializers/session_store.rb like below

s.application.config.session_store SessionStoreRelocator::CookieToRedis, {
okie_store: { key: '_myapp_session' },
dis_session_store: {
key: 'myapp_session:',
redis: {
  url: ENV['SESSION_REDIS_URL'],
  expire_after: 2.weeks,
  key_prefix:  'myapp_session:',
},
serializer: :json,


See each documents for detail.

Step2. Switch to new store

After some days with copying session data, you switch store simply remove this gem. Then configuration will be like below.

s.application.config.session_store RedisSessionStore, {
y: 'myapp_session:',
dis: {
url: ENV['SESSION_REDIS_URL'],
expire_after: 2.weeks,
key_prefix:  'myapp_session:',

rializer: :json,

Contributing
  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request
License

The gem is available as open source under the terms of the MIT License.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.