I'm trying to configure Rails 3 cache_store with something like this in environments/development.rb:
config.cache_store = :memory_store, {:size => 64.megabytes, :expires_in => 5.minutes}
But when i start server i get:
undefined method `megabytes' for 64:Fixnum (NoMethodError)
Probably something is not loaded yet.
My question is: where is the right place to configure it them? Where should i place this code?
Page caches are always stored on disk. Rails 2.1 and above provide ActiveSupport::Cache::Store which can be used to cache strings. Some cache store implementations, like MemoryStore, are able to cache arbitrary Ruby objects, but don't count on every cache store to be able to do that.
Alternatively, you can set ActionController::Base. cache_store outside of a configuration block. You can access the cache by calling Rails. cache .
In computing, a cache is a high-speed data storage layer which stores a subset of data, typically transient in nature, so that future requests for that data are served up faster than is possible by accessing the data's primary storage location.
Or else add this line
require 'active_support/core_ext/numeric/bytes'
before
config.cache_store = :memory_store, {:size => 64.megabytes, :expires_in => 5.minutes}
Use ActionController::Base.cache_store =
and place in an initializer file (create an rb file in config/initializers)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With