Fast Sessions plugin
Plugin details
Documentation
ruby script/plugin install http://rails-fast-sessions.googlecode.com/svn/trunk
==Controversial Decisions==
Many plugin users would never think about one problem we've introduced when removed that auto-increment primary key, so I'd like to describe it here. The problem is following.
`InnoDB` groups all data in tables by primary key. This means that when we create auto-increment primary key and insert records to a table, our sessions records are grouped together and saved sequentially on the disk. But if we'll make pretty random value (like crc32 of a random session id) a primary key, then every session record will be inserted in its own place and it will generate some random I/O which is not so good for I/O bound servers.
So, we decided to let the user choose what primary key to use in his deployment of our plugin, so if you're going to use this module with MySQL 5.1.22+, then you'dlike to set
CGI::Session::ActiveRecordStore::FastSessions.use_auto_increment = true
because it will provide you with consecutive data inserts in InnoDB. Another cases when you'd like to use it is when your MySQL server is I/O bound now and you do not want to add random I/O because of randomized primary key.
==Working With Old AR Sessions Table==
If you do not like to loose old sessions created with default AR sessions plugin, you could set
CGI::Session::ActiveRecordStore::FastSessions.fallback_to_old_table = true
and then all session reads will fall back to old sessions table if some session_id was not found in default fast sessions table. Old sessions table name could be set using
CGI::Session::ActiveRecordStore::FastSessions.old_table_name
variable.
==Installation==
Enable `ActiveRecord` session store in your `config/environment.rb` file:
Rails::Initializer.run do |config| ...... config.action_controller.session_store = :active_record_store ...... end
Create migration for your new sessions table:
./script/generate fast_session_migration AddFastSessions
Open your newly created migration and change `table_name` and `use_auto_increment` parameters of the plugin (if you want to).
Run your migration:
rake db:migrate
Start your application and try to perform some actions which would definitely save some data to your session. Then check your `fast_sessions` table (if you did not renamed it) for a records.
Further Documentation
There is currently no advanced documentation for this plugin.
New documentationEdit plugin | (0 older versions) | Last edited by: Guest, 3 months ago

