Dalli as cache store

258 views
Skip to first unread message

joshmckin

unread,
Dec 6, 2010, 2:20:46 PM12/6/10
to SimpleRecord
I'm using Dalli on heroku for my session store and would like to use
it (Dalli) as a cache store for SimpleRecord, but get following error

undefined method `write' for #<Dalli::Client:0x00000103c62268>

/Users/joshmckin/.rvm/gems/ruby-1.9.2-p0/gems/simple_record-1.5.8/lib/
simple_record.rb:1003:in `block in cache_results'
/Users/joshmckin/.rvm/gems/ruby-1.9.2-p0/gems/simple_record-1.5.8/lib/
simple_record.rb:998:in `each'
/Users/joshmckin/.rvm/gems/ruby-1.9.2-p0/gems/simple_record-1.5.8/lib/
simple_record.rb:998:in `cache_results'
/Users/joshmckin/.rvm/gems/ruby-1.9.2-p0/gems/simple_record-1.5.8/lib/
simple_record.rb:930:in `find'
/Users/joshmckin/.rvm/gems/ruby-1.9.2-p0/gems/simple_record-1.5.8/lib/
simple_record/active_sdb.rb:438:in `select_all_by_'
/Users/joshmckin/.rvm/gems/ruby-1.9.2-p0/gems/simple_record-1.5.8/lib/
simple_record/active_sdb.rb:443:in `select_by_'
/Users/joshmckin/.rvm/gems/ruby-1.9.2-p0/gems/simple_record-1.5.8/lib/
simple_record/active_sdb.rb:589:in `method_missing'

Is it possible that I have a my cache store setup wrong, or does
Simple Record not support Dalli?

Travis Reeder

unread,
Dec 6, 2010, 5:02:50 PM12/6/10
to simple...@googlegroups.com
SimpleRecord uses the ActiveSupport::Cache::Store interface so it looks like you'll want to use the DalliStore here: https://github.com/mperham/dalli/blob/master/lib/active_support/cache/dalli_store23.rb

Similar to how it's used in the Rails 2.3.8 section in the README: https://github.com/mperham/dalli#readme

dalli_store = ActiveSupport::Cache::DalliStore.new
SimpleRecord::Base.cache_store = dalli_store


--
You received this message because you are subscribed to the Google Groups "SimpleRecord" group.
To post to this group, send email to simple...@googlegroups.com.
To unsubscribe from this group, send email to simple-recor...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/simple-record?hl=en.


joshmckin

unread,
Dec 6, 2010, 10:04:52 PM12/6/10
to SimpleRecord
Thanks Travis.

I put this in the production.rb and it appears to be working:

require 'active_support/cache/dalli_store23'
dalli_store = ActiveSupport::Cache::DalliStore.new
SimpleRecord::Base.cache_store = dalli_store

Josh

On Dec 6, 4:02 pm, Travis Reeder <tree...@gmail.com> wrote:
> SimpleRecord uses the ActiveSupport::Cache::Store interface so it looks like
> you'll want to use the DalliStore here:https://github.com/mperham/dalli/blob/master/lib/active_support/cache...
> > simple-recor...@googlegroups.com<simple-record%2Bunsubscribe@goog legroups.com>
> > .
Reply all
Reply to author
Forward
0 new messages