3

I am using:

  • Rails 4.1.0rc2
  • Heroku
  • gem 'memcachier'
  • gem 'dalli'

If I use caching from the console, it works:

irb(main):010:0> Rails.cache.write("foo", "bar")
=> 1297036692682702848
irb(main):011:0> Rails.cache.read("foo")
=> "bar"

But if I set the cache using Rails.cache.fetch in the application, and attempt to read via the console, I get this.

Rails.cache.read([School, "California", [], School.where(state: "California").all.map(&:updated_at).max, "city_filters"])
Dalli::Server#connect mc3.dev.ec2.memcachier.com:11211
Dalli/SASL authenticating as 451265
Dalli/SASL authenticating as 451265
Dalli/SASL: 451265
Dalli/SASL: 451265
=> [{:type=>"city", :value=>"San Francisco", :count=>11, :current=>false}]

But when I run this in the app, it does a new search each time.

Completed 200 OK in 8481ms (Views: 1151.4ms | ActiveRecord: 246.6ms)

Caching works locally (it's not a full cache).

Completed 200 OK in 655ms (Views: 244.5ms | ActiveRecord: 74.5ms)

How can I get memcached/dalli working? I had this working in a different app; seems like the same set up to me.

miler350
  • 1,411
  • 11
  • 15

2 Answers2

1

Make sure you provision memcachier addon on heroku and that you have its credentials in your environment (run: heroku config). Also make sure your memcachier & dalli gems are not nested in any gem group so that they are available in production.

hammady
  • 969
  • 1
  • 13
  • 22
-4

Are you using a free paln on heroku ? You might need to add dynos on heroku to boost up processing speed of your application on heroku.

check out : https://devcenter.heroku.com/articles/dynos

  • I am using the free version but I thought dynos didn't help with speed. Even still, shouldn't I still see an attempt to read the cache in the logs? – miler350 Apr 14 '14 at 22:08