Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

memcached #25

Open
rickthomasjr opened this issue Mar 21, 2011 · 7 comments
Open

memcached #25

rickthomasjr opened this issue Mar 21, 2011 · 7 comments

Comments

@rickthomasjr
Copy link

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
Copy link
Member

treeder commented Mar 22, 2011

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 <
[email protected]>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:
#25

@rickthomasjr
Copy link
Author

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 <
[email protected]>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 <
[email protected]>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:
#25

Reply to this email directly or view it on GitHub:
#25 (comment)

@rickthomasjr
Copy link
Author

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 [email protected] 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 <
[email protected]>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 <
[email protected]>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:
#25

Reply to this email directly or view it on GitHub:
#25 (comment)

@rickthomasjr
Copy link
Author

Any more thoughts on this issue?

@treeder
Copy link
Member

treeder commented Apr 14, 2011

You get the undefined method `write' error?

Can you post backtrace?

@rickthomasjr
Copy link
Author

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
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants