Prev | Current Page 268 | Next

Brad Ediger

"Advanced Rails"

When
configured, it takes one argument, the path to the cache directory:
config.action_controller.fragment_cache_store = :file_store,
"/var/rails/fragment_cache"
The DRbStore (fragment_cache_store = :drb_store) requires a running DRb server to
store the fragments. It takes a single configuration argument: the URI of the DRb server
(druby://drb_server_name:9192/). Finally, the MemCacheStore (:mem_cache_store) uses
a memcached server. Its argument is the hostname or IPaddress of the server running
memcached.
It is technically possible to use the same memcached server for session storage and
caching, as session IDs and fragment cache names are not likely to collide (Mem-
CacheStore session keys begin with session:). However, this is not recommended.
Sessions and fragment caching have fundamentally different needs, and it is not terribly
difficult to set up multiple memcached servers (use the -p option to specify a port
number). I recommend keeping separate concerns separated.
Cache stores have more flexibility than session stores when scaling upward. Though
a session must always be reliably available to all of the application servers, you don??™t
lose anything from a fragment cache miss (except a small performance penalty as you
have to regenerate the content). Therefore, you could theoretically decide to give
each application server its own memory fragment cache.


Pages:
256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280