It provides the necessary subset of
ActiveRecord to handle sessions. Activate it by manually changing the session class:
CGI::Session::ActiveRecordStore.session_class =
CGI::Session::ActiveRecordStore::SqlBypass
Of course, you can easily write your own classes that talk to the session database, and
plug them in by this mechanism. The RDoc on CGI::Session::ActiveRecordStore
explains the exact requirements.
MemCacheStore
The MemCacheStore is a grown-up version of the DRbStore (a very simple centralized
in-memory session store). It uses Danga Interactive??™s memcached daemon to store
sessions. (memcached is discussed in detail in Chapter 4.) For scalability purposes,
memcached is usually preferable to the DRbStore, except in very small settings.
To activate the MemCacheStore, you must install the ruby-memcache gem (gem
install ruby-memcache). Then, start up a memcached server on an appropriate
machine. This command will tell memcached to use up to 512 MB of RAM, listen on
port 11211 (the default memcached port), and daemonize itself:
memcached -d -m 512 -p 11211
Then, set the Rails session store to the MemCacheStore:
config.action_controller.session_store = :mem_cache_store
Any options can be set with the session method. For example, you can specify multiple
memcached servers to balance requests:
class ApplicationController
session :cache => MemCache.new('10.
Pages:
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273