appoxy / simple_record

An ActiveRecord like interface for SimpleDB. Can be used as a drop in replacement for ActiveRecord in rails.
http://www.appoxy.com
MIT License
129 stars 29 forks source link

memcached #25

Open rickthomasjr opened 13 years ago

rickthomasjr commented 13 years ago

I cannot figure out how to get caching working with either memcached or dalli. This code: store = :memcache_store, 'localhost', { :namespace => 'my_program', :expires_in => 1.day, :compress => true, :compress_threshold => 64*1024 } SimpleRecord::Base.cache_store = store

results in undefined method `write' for #Array:0x00000101b80540

* file: simple_record.rb
* location: cache_results
* line: 1061

I'm working in Sinatra.

treeder commented 13 years ago

You have to use the ActiveSupport cache interface, see this post for more info: https://groups.google.com/d/topic/simple-record/RMpVz3BXHew/discussion

On Mon, Mar 21, 2011 at 12:06 PM, rickthomasjr < reply@reply.github.com>wrote:

I cannot figure out how to get caching working with either memcached or dalli. This code: store = :memcache_store, 'localhost', { :namespace => 'my_program', :expires_in => 1.day, :compress => true, :compress_threshold => 64*1024 } SimpleRecord::Base.cache_store = store

results in undefined method `write' for #Array:0x00000101b80540

  • file: simple_record.rb
  • location: cache_results
  • line: 1061

I'm working in Sinatra.

Reply to this email directly or view it on GitHub: https://github.com/appoxy/simple_record/issues/25

rickthomasjr commented 13 years ago

Thanks for the tip. When I try this,

require 'simple_record' require 'active_support/cache/dalli_store23' dalli_store = ActiveSupport::Cache::DalliStore.new, 'localhost', { :namespace => 'gst_api', :expires_in => 1.day} SimpleRecord::Base.cache_store = dalli_store

I get the same error.

Also, if I remove the "localhost" and the options array from the DalliStore instanciation, I get this: undefined method `merge' for nil:NilClass

Do you have any reason to believe this won't work with Sinatra?

Thanks for your attention.

On Tue, Mar 22, 2011 at 1:33 AM, treeder < reply@reply.github.com>wrote:

You have to use the ActiveSupport cache interface, see this post for more info: https://groups.google.com/d/topic/simple-record/RMpVz3BXHew/discussion

On Mon, Mar 21, 2011 at 12:06 PM, rickthomasjr < reply@reply.github.com>wrote:

I cannot figure out how to get caching working with either memcached or dalli. This code: store = :memcache_store, 'localhost', { :namespace => 'my_program', :expires_in => 1.day, :compress => true, :compress_threshold => 64*1024 } SimpleRecord::Base.cache_store = store

results in undefined method `write' for #Array:0x00000101b80540

  • file: simple_record.rb
  • location: cache_results
  • line: 1061

I'm working in Sinatra.

Reply to this email directly or view it on GitHub: https://github.com/appoxy/simple_record/issues/25

Reply to this email directly or view it on GitHub: https://github.com/appoxy/simple_record/issues/25#comment_901729

rickthomasjr commented 13 years ago

Also, FWIW, local_cache worked fine. Unfortunately that's not appropriate for our application long-term.

On Tue, Mar 22, 2011 at 8:35 AM, Rick Thomas rick@rtindy.com wrote:

Thanks for the tip. When I try this,

require 'simple_record' require 'active_support/cache/dalli_store23' dalli_store = ActiveSupport::Cache::DalliStore.new, 'localhost', { :namespace => 'gst_api', :expires_in => 1.day} SimpleRecord::Base.cache_store = dalli_store

I get the same error.

Also, if I remove the "localhost" and the options array from the DalliStore instanciation, I get this: undefined method `merge' for nil:NilClass

  • file: cache.rb
  • location: merged_options
  • line: \ 477

Do you have any reason to believe this won't work with Sinatra?

Thanks for your attention.

On Tue, Mar 22, 2011 at 1:33 AM, treeder < reply@reply.github.com>wrote:

You have to use the ActiveSupport cache interface, see this post for more info: https://groups.google.com/d/topic/simple-record/RMpVz3BXHew/discussion

On Mon, Mar 21, 2011 at 12:06 PM, rickthomasjr < reply@reply.github.com>wrote:

I cannot figure out how to get caching working with either memcached or dalli. This code: store = :memcache_store, 'localhost', { :namespace => 'my_program', :expires_in => 1.day, :compress => true, :compress_threshold => 64*1024 } SimpleRecord::Base.cache_store = store

results in undefined method `write' for #Array:0x00000101b80540

  • file: simple_record.rb
  • location: cache_results
  • line: 1061

I'm working in Sinatra.

Reply to this email directly or view it on GitHub: https://github.com/appoxy/simple_record/issues/25

Reply to this email directly or view it on GitHub: https://github.com/appoxy/simple_record/issues/25#comment_901729

rickthomasjr commented 13 years ago

Any more thoughts on this issue?

treeder commented 13 years ago

You get the undefined method `write' error?

Can you post backtrace?

rickthomasjr commented 13 years ago

In the merged_options method, options is nil:

undefined method `merge' for nil:NilClass

file: cache.rb
location: merged_options
line: 480

/Users/rickthomas/.rvm/gems/ruby-1.9.2-p136@sinatra/gems/activesupport-3.0.5/lib/active_support/cache.rb in merged_options

options.merge(call_options)

/Users/rickthomas/.rvm/gems/ruby-1.9.2-p136@sinatra/gems/activesupport-3.0.5/lib/active_support/cache.rb in write

options = merged_options(options)

/Users/rickthomas/.rvm/gems/ruby-1.9.2-p136@sinatra/gems/dalli-1.0.3/lib/active_support/cache/dalli_store23.rb in write

super

/Users/rickthomas/.rvm/gems/ruby-1.9.2-p136@sinatra/gems/simple_record-2.1.3/lib/simple_record.rb in cache_results

cache_store.write(cache_key, results, :expires_in =>30)

/Users/rickthomas/.rvm/gems/ruby-1.9.2-p136@sinatra/gems/simple_record-2.1.3/lib/simple_record.rb in save_super

self.class.cache_results(self)

/Users/rickthomas/.rvm/gems/ruby-1.9.2-p136@sinatra/gems/simple_record-2.1.3/lib/simple_record.rb in do_actual_save

return save_super(dirty, is_create, options, to_delete)

/Users/rickthomas/.rvm/gems/ruby-1.9.2-p136@sinatra/gems/simple_record-2.1.3/lib/simple_record.rb in block in update

x = do_actual_save(options)

/Users/rickthomas/.rvm/gems/ruby-1.9.2-p136@sinatra/gems/activesupport-3.0.5/lib/active_support/callbacks.rb in _run_update_callbacks

/Users/rickthomas/.rvm/gems/ruby-1.9.2-p136@sinatra/gems/simple_record-2.1.3/lib/simple_record.rb in update

_run_update_callbacks do

/Users/rickthomas/.rvm/gems/ruby-1.9.2-p136@sinatra/gems/simple_record-2.1.3/lib/simple_record.rb in block in create_or_update

result = new_record? ? create(options) : update(options)

/Users/rickthomas/.rvm/gems/ruby-1.9.2-p136@sinatra/gems/activesupport-3.0.5/lib/active_support/callbacks.rb in _run_save_callbacks

end

/Users/rickthomas/.rvm/gems/ruby-1.9.2-p136@sinatra/gems/simple_record-2.1.3/lib/simple_record.rb in create_or_update

_run_save_callbacks do

/Users/rickthomas/.rvm/gems/ruby-1.9.2-p136@sinatra/gems/simple_record-2.1.3/lib/simple_record.rb in save

ok = create_or_update(options)

/Users/rickthomas/Projects/goldshark/goldshark.rb in block in <top (required)>

@session.save unless @session.nil?
rickthomasjr commented 13 years ago

If dalli won't work, is there another memcached client I might consider? Am I the only one having this problem?