Every repository with this icon (
Every repository with this icon (
| Description: | A Write-Through Cacheing Library for ActiveRecord edit |
-
When I ran with the Locale plugin I got this error:
NoMethodError (You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.indices):
(DELEGATION):2:in__send__' (__DELEGATION__):2:inindices' (DELEGATION):2:in__send__' (__DELEGATION__):2:inindices' vendor/gems/nkallen-cache-money-0.2.5/lib/cash/query/abstract.rb:114:inindexed_on?' vendor/gems/nkallen-cache-money-0.2.5/lib/cash/query/abstract.rb:56:incacheable?' vendor/gems/nkallen-cache-money-0.2.5/lib/cash/query/abstract.rb:15:inperform' vendor/gems/nkallen-cache-money-0.2.5/lib/cash/query/abstract.rb:7:inperform' vendor/gems/nkallen-cache-money-0.2.5/lib/cash/finders.rb:24:infind_every' vendor/gems/mislav-will_paginate-2.2.3/lib/will_paginate/finder.rb:164:inmethod_missing' app/controllers/application_controller.rb:69:in `set_locale_from_request'Which was caused by the Locale ActiveRecords being located in the vendor tree and not our main tree. To solve this we added this line to abstract.rb:52
def cacheable?(*optionss)return false unless @active_record.methods.include?(:indices) optionss.each { |options| return unless safe_options_for_cache?(options) }
Comments
-
Can you provide an example on how to properly index fields in the (automagically generated) "join" table that rails creates when 2 models are declared as habtm?
For example:
class Role < ActiveRecord::Basehas_and_belongs_to_many :users
end
class User < ActiveRecord::Base
has_and_belongs_to_many :roles
end
Then, how do I properly index the "role_id" and "user_id" columns in the automatically generated "roles_users" table?
It seems that cache-money requires index declarations in all models, but the problem is, there's no actual model file declared for the "roles_users" table. So, do I need to manually create the model file...? Or is there some other way to accomplish what I want?
Thanks.
Comments
-
I feel cache_money is great, especially for its support of transaction. I haven't seen any others provide such feature.
However, I need to use rails as the backend of a Flex project, and use rubyamf (http://code.google.com/p/rubyamf/) to communicate with the front side. When an ActiveRecord (e.g. User) is configured with class mapping:ClassMappings.register( :actionscript => 'model.UserModel', :ruby => 'User', :type => 'active_record', :attributes => ["id", "name"], :associations =>{ :for_default=>[] })User.find 1 reports some error:
NoMethodError: You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.indices
from (__DELEGATION__):2:in `__send__' from (__DELEGATION__):2:in `indices' from (__DELEGATION__):2:in `__send__' from (__DELEGATION__):2:in `indices' from /home/clive/ruby/RailsApplication1/vendor/plugins/nkallen-cache-money/lib/cash/query/abstract.rb:114:in `indexed_on?' from /home/clive/ruby/RailsApplication1/vendor/plugins/nkallen-cache-money/lib/cash/query/abstract.rb:56:in `cacheable?' from /home/clive/ruby/RailsApplication1/vendor/plugins/nkallen-cache-money/lib/cash/query/abstract.rb:15:in `perform' from /home/clive/ruby/RailsApplication1/vendor/plugins/nkallen-cache-money/lib/cash/query/primary_key.rb:17:in `perform' from /home/clive/ruby/RailsApplication1/vendor/plugins/nkallen-cache-money/lib/cash/query/abstract.rb:7:in `perform' from /home/clive/ruby/RailsApplication1/vendor/plugins/nkallen-cache-money/lib/cash/finders.rb:29:in `find_from_ids' from /home/clive/ruby/RailsApplication1/vendor/rails/activerecord/lib/active_record/base.rb:590:in `find' from (irb):1and index [:name] in User class also reports:
home/clive/ruby/RailsApplication1/vendor/rails/activerecord/lib/active_record/base.rb:1833:inmethod_missing':NoMethodError: undefined methodindex' for #<Class:0xb730f374>I couldn't find a way to attach the rails project I created here. If some one has problem in reproduce the issue, feel free to contact me
Comments
-
Hi Nick,
Occasionally, I get the following "Cash::Lock::Error" and was wondering if you could shed some light as to whether cache-money or memcached generated the underlying issue:... /var/lib/gems/1.8/gems/memcached-0.14/lib/memcached/memcached.rb:389:in `check_return_code': Key {"lock/Url:7/client_id/19799"=>"172.16.164.42:11211:8"} Cash::Lock::Error
If it's an error that's ultimately generated by memcached, I assume there's no way to fix it at any other level (e.g., in rails). Is that a fair assessment?
Thanks,
-- DarienComments
This error is caused when cache-money cannot get add a lock value to memcache. Cache-money tries a '@cache.add("lock/#{key}", Process.pid, lock_expiry)'. If this fails it waits for a period of time (which increases with each retry) then retries. It repeats for a default of 5 times.
We did not see this error until our production system was under load, not the best time to see this error, and then it occurs a lot.
If you have any ideas WRT fixing this error let us know.
-
I am on ruby 1.8.7 , Rails 2.3.2 , cache-money 0.2.5
This works
Location.new(:lat => 12.1, :lng => 12.2)
, lng: #<BigDecimal:3e33df4,'0.122E2',8(8)>, address: nil, city: nil, state: nil, country: nil, pincode: nil, created_at: nil, updated_at: nil>
This fails
Location.create(:lat => 12.1, :lng => 12.2)
ArgumentError: wrong number of arguments (4 for 2)
from /vendor/gems/nkallen-cache-money-0.2.5/lib/cash/buffered.rb:123:in `set' from /vendor/gems/nkallen-cache-money-0.2.5/lib/cash/buffered.rb:123:in `send' from /vendor/gems/nkallen-cache-money-0.2.5/lib/cash/buffered.rb:123:in `call' from /vendor/gems/nkallen-cache-money-0.2.5/lib/cash/buffered.rb:94:in `perform_commands' from /vendor/gems/nkallen-cache-money-0.2.5/lib/cash/buffered.rb:93:in `each' from /vendor/gems/nkallen-cache-money-0.2.5/lib/cash/buffered.rb:93:in `perform_commands' from /vendor/gems/nkallen-cache-money-0.2.5/lib/cash/buffered.rb:75:in `flush' from /vendor/gems/nkallen-cache-money-0.2.5/lib/cash/transactional.rb:19:in `transaction' from /vendor/gems/nkallen-cache-money-0.2.5/lib/cache_money.rb:50:in `transaction' from /vendor/rails/activerecord/lib/active_record/transactions.rb:228:in `with_transaction_returning_status' from /vendor/rails/activerecord/lib/active_record/transactions.rb:196:in `save' from /vendor/rails/activerecord/lib/active_record/transactions.rb:208:in `rollback_active_record_state!' from /vendor/rails/activerecord/lib/active_record/transactions.rb:196:in `save' from /vendor/rails/activerecord/lib/active_record/base.rb:728:in `create' from (irb):1Help with this...
Comments
This is fixed in , http://github.com/parolkar/cache-money/tree/master
-
?> x = Package.find_by_name "Platinum Pack" SQL (0.1ms) SET SQL_AUTO_IS_NULL=0 Package Columns (1.2ms) SHOW FIELDS FROM `packages` Package Load (0.2ms) SELECT * FROM `packages` WHERE (`packages`.`name` = 'Platinum Pack') LIMIT 1 => # >> x.send :all_package_ids AssociatedPackage Columns (1.1ms) SHOW FIELDS FROM `associated_packages` AssociatedPackage Load (0.2ms) SELECT * FROM `associated_packages` WHERE (`associated_packages`.`id` = 7) AND (`associated_packages`.package_id = 21) => [21, 20, 19] >> x.send :all_package_ids SystemStackError: stack level too deep from /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/core_ext/hash/except.rb:18:in `except!' from /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/core_ext/hash/except.rb:13:in `except' from /opt/local/lib/ruby/gems/1.8/gems/nkallen-cache-money-0.2.5/lib/cash/query/abstract.rb:78:in `safe_options_for_cache?' from /opt/local/lib/ruby/gems/1.8/gems/nkallen-cache-money-0.2.5/lib/cash/query/abstract.rb:52:in `cacheable?' from /opt/local/lib/ruby/gems/1.8/gems/nkallen-cache-money-0.2.5/lib/cash/query/abstract.rb:52:in `each' from /opt/local/lib/ruby/gems/1.8/gems/nkallen-cache-money-0.2.5/lib/cash/query/abstract.rb:52:in `cacheable?' from /opt/local/lib/ruby/gems/1.8/gems/nkallen-cache-money-0.2.5/lib/cash/query/abstract.rb:15:in `perform' from /opt/local/lib/ruby/gems/1.8/gems/nkallen-cache-money-0.2.5/lib/cash/query/abstract.rb:7:in `perform' from /opt/local/lib/ruby/gems/1.8/gems/nkallen-cache-money-0.2.5/lib/cash/finders.rb:24:in `find_every' from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/base.rb:1583:in `find_one' from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/base.rb:1569:in `find_from_ids_without_cache' from /opt/local/lib/ruby/gems/1.8/gems/nkallen-cache-money-0.2.5/lib/cash/query/abstract.rb:6:in `__send__' from /opt/local/lib/ruby/gems/1.8/gems/nkallen-cache-money-0.2.5/lib/cash/query/abstract.rb:6:in `find_from_ids_without_cache' from /opt/local/lib/ruby/gems/1.8/gems/nkallen-cache-money-0.2.5/lib/cash/query/abstract.rb:158:in `find_from_keys' from /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/core_ext/module/delegation.rb:122:in `to_proc' from /opt/local/lib/ruby/gems/1.8/gems/nkallen-cache-money-0.2.5/lib/cash/accessor.rb:17:in `call' ... 4742 levels... from /opt/local/lib/ruby/gems/1.8/gems/nkallen-cache-money-0.2.5/lib/cash/query/abstract.rb:19:in `perform' from /opt/local/lib/ruby/gems/1.8/gems/nkallen-cache-money-0.2.5/lib/cash/query/abstract.rb:7:in `perform' from /opt/local/lib/ruby/gems/1.8/gems/nkallen-cache-money-0.2.5/lib/cash/finders.rb:24:in `find_every' from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/base.rb:615:in `find' from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/base.rb:635:in `all' from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/associations/association_collection.rb:379:in `send' from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/associations/association_collection.rb:379:in `method_missing' from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/base.rb:2143:in `with_scope' from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/associations/association_proxy.rb:206:in `send' from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/associations/association_proxy.rb:206:in `with_scope' from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/associations/association_collection.rb:375:in `method_missing' from /xxx/app/models/package.rb:43:in `parent_packages' from /xxx/app/models/package.rb:96:in `all_package_ids' from (irb):78:in `send' from (irb):78 from :0>> # == Schema Information # # Table name: packages_channels # # channel_id :integer(4) # package_id :integer(4) # id :integer(4) not null, primary key # class PackagesChannel < ActiveRecord::Base belongs_to :package belongs_to :channel # memcache indexes index :id index :package_id index [:package_id, :channel_id] end class Package < ActiveRecord::Base has_many :associated_packages def parent_packages # to make things mem_cache friendly (avoiding joins) associated_packages.all.collect{|assoc| assoc.associated_package} end def all_package_ids [self.id] + self.parent_packages.map{|pkg| pkg.all_package_ids}.flatten end endComments
-
13 test failures all on mock(Story).get.never...
0 comments Created 2 months ago by wiseleybAll mock(Story).get.never calls are failing with ArgumentError in ... wrong number of arguments (0 for 1)
I'm on Rails 2.3.3, Ruby 1.8.7, Mac OSX, memcached 1.2.5 (on libevent 1.4.12-stable) is running and receiving requests. Using Cache-money 0.2.5. RR is version 0.10.2
Test config memcache config looks like:
test:
ttl: 604800 namespace: deucescracked sessions: false debug: false servers: localhost:11211Complete run...
Mac-san:cache_money wiseleyb$ rake
(in /Users/wiseleyb/Dev/dc/deucescracked/vendor/plugins/cache_money) /usr/local/bin/ruby -I"lib:test" "/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb"
/usr/local/bin/ruby -I"lib:test" "/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb"
/usr/local/bin/ruby -I"lib:test" "/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb"
-- create_table("stories", {:force=>true}) -> 0.2287s -- create_table("characters", {:force=>true}) -> 0.0022s -- initialize_schema_migrations_table() -> 0.0027s -- assume_migrated_upto_version(2) -> 0.0012s Profiling enabled.
...........................................FF.F......FFFF......F......F..FF...F...................................................................................................................F...**..Top 10 slowest examples:
0.7442140 Windows#find(...) when the cache is not populated#find(:all, :conditions => ..., :limit => ...) and query limit <= index limit when there are fewer than limit + buffer items populates the cache with all items
0.6272080 Windows#destroy when the cache is populated when the index size is <= limit of items when the count of records in the database is >= limit of items refreshes the list (from the database)
0.6196620 Windows#destroy when the cache is not populated when count of records in the database is <= limit of items when the count of records in the database is between limit and limit + buffer items populates the index
0.6155840 Windows#find(...) when the cache is populated#find(:all, :conditions => ...) uses the database, not the cache
0.6027420 Windows#find(...) when the cache is populated#find(:all, :conditions => ..., :limit => ...) and query limit > index limit uses the database, not the cache
0.5723260 Windows#find(...) when the cache is populated#find(:all, :conditions => ..., :limit => ..., :offset => ...) and query limit + offset > index limit uses the database, not the cache
0.5702350 Windows#find(...) when the cache is not populated#find(:all, :conditions => ..., :limit => ...) and query limit <= index limit when there are more than limit + buffer items populates the cache with limit + buffer items
0.5175020 Windows#find(...) when the cache is populated#find(:all, :conditions => ..., :limit => ...) and query limit <= index limit does not use the database
0.5068240 Cash::Lock#acquire_lock prevents two processes from acquiring the same lock at the same time
0.5023990 Windows#create! when the cache is not populated when the count of records in the database is > limit + buffer items truncates the indexPending:
Cash::WriteThrough Locking acquires and releases locks, in order, for all indices to be written (TODO)
./spec/cash/write_through_spec.rb:172Cash::WriteThrough Locking acquires and releases locks on destroy (TODO)
./spec/cash/write_through_spec.rb:1831)
ArgumentError in 'Cash::Finders Calculations when the cache is populated#count(:column, :conditions => ...) uses the database, not the cache'
wrong number of arguments (0 for 1)
./spec/cash/calculations_spec.rb:19:2)
ArgumentError in 'Cash::Finders Calculations when the cache is populated#count(:all, :distinct => ..., :select => ...) uses the database, not the cache'
wrong number of arguments (0 for 1)
./spec/cash/calculations_spec.rb:26:3)
ArgumentError in 'Cash::Finders Calculations when the cache is not populated#count(:all, ...)#count(:all) uses the database, not the cache'
wrong number of arguments (0 for 1)
./spec/cash/calculations_spec.rb:47:4)
ArgumentError in 'Cash::Finders Cache Usage when the cache is populated#find#find(:first, ...)#find(:first, :readonly => true) uses the database, not the cache'
wrong number of arguments (0 for 1)
./spec/cash/finders_spec.rb:54:5)
ArgumentError in 'Cash::Finders Cache Usage when the cache is populated#find#find(:first, ...)#find(:first, :join => ...) or find(..., :include => ...) uses the database, not the cache'
wrong number of arguments (0 for 1)
./spec/cash/finders_spec.rb:62:6)
ArgumentError in 'Cash::Finders Cache Usage when the cache is populated#find#find(:first, ...)#find(:first) uses the database, not the cache'
wrong number of arguments (0 for 1)
./spec/cash/finders_spec.rb:70:7)
ArgumentError in 'Cash::Finders Cache Usage when the cache is populated#find#find(:first, ...)#find(:first, :conditions => "...") on unindexed attributes uses the database, not the cache'
wrong number of arguments (0 for 1)
./spec/cash/finders_spec.rb:79:8)
ArgumentError in 'Cash::Finders Cache Usage when the cache is populated#find#find(:first, ...)#find(:first, :conditions => {...}) on unindexed attribtes uses the database, not the cache'
wrong number of arguments (0 for 1)
./spec/cash/finders_spec.rb:142:9)
ArgumentError in 'Cash::Finders Cache Usage when the cache is populated#find#find(:all) uses the database, not the cache'
wrong number of arguments (0 for 1)
./spec/cash/finders_spec.rb:217:10)
ArgumentError in 'Cash::Finders Cache Usage when the cache is populated#find#find([...])#find([1, 2, ...], :conditions => ...) uses the database, not the cache'
wrong number of arguments (0 for 1)
./spec/cash/finders_spec.rb:250:11)
ArgumentError in 'Cash::Finders Cache Usage when the cache is populated#find#find([...])#find([1], :conditions => ...) uses the database, not the cache'
wrong number of arguments (0 for 1)
./spec/cash/finders_spec.rb:258:12)
ArgumentError in 'Cash::Finders Cache Usage when the cache is populated#without_cache when finders are called within the provided block uses the database not the cache'
wrong number of arguments (0 for 1)
./spec/cash/finders_spec.rb:302:13)
ArgumentError in 'Cash::WriteThrough ClassMethods after destroy when the object is a new record does nothing'
wrong number of arguments (0 for 2)
./spec/cash/write_through_spec.rb:134:Finished in 15.381762 seconds
202 examples, 13 failures, 2 pending
rake aborted!
Command /usr/local/bin/ruby -I"/Users/wiseleyb/.gem/ruby/1.8/gems/rspec-1.2.8/lib" "/Users/wiseleyb/.gem/ruby/1.8/gems/rspec-1.2.8/bin/spec" "spec/cash/accessor_spec.rb" "spec/cash/active_record_spec.rb" "spec/cash/calculations_spec.rb" "spec/cash/finders_spec.rb" "spec/cash/lock_spec.rb" "spec/cash/order_spec.rb" "spec/cash/transactional_spec.rb" "spec/cash/window_spec.rb" "spec/cash/write_through_spec.rb" --format profile --color failedComments
-
.find # doesn't work until you do a find_by_id
1 comment Created 2 months ago by wiseleybI'm on Rails 2.3.3, Ruby 1.8.7, Mac OSX, memcached 1.2.5 (on libevent 1.4.12-stable) is running and receiving requests. Using Cache-money 0.2.5. RR is version 0.10.2
If I do a BlogEntry.find(2) it fails with:
ActiveRecord::RecordNotFound: Couldn't find BlogEntry with ID=0
from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/base.rb:1586:in `find_one' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/base.rb:1569:in `find_from_ids_without_cache' from /Users/wiseleyb/Dev/dc/deucescracked/vendor/plugins/cache_money/lib/cash/query/abstract.rb:6:in `__send__' from /Users/wiseleyb/Dev/dc/deucescracked/vendor/plugins/cache_money/lib/cash/query/abstract.rb:6:in `find_from_ids_without_cache' from /Users/wiseleyb/Dev/dc/deucescracked/vendor/plugins/cache_money/lib/cash/query/abstract.rb:158:in `find_from_keys' from /Users/wiseleyb/Dev/dc/deucescracked/vendor/plugins/cache_money/lib/cash/query/primary_key.rb:31:in `miss' from /Users/wiseleyb/Dev/dc/deucescracked/vendor/plugins/cache_money/lib/cash/query/abstract.rb:66:in `hit_or_miss' from /Users/wiseleyb/Dev/dc/deucescracked/vendor/plugins/cache_money/lib/cash/accessor.rb:17:in `call' from /Users/wiseleyb/Dev/dc/deucescracked/vendor/plugins/cache_money/lib/cash/accessor.rb:17:in `fetch' from /Users/wiseleyb/Dev/dc/deucescracked/vendor/plugins/cache_money/lib/cash/accessor.rb:29:in `get' from /Users/wiseleyb/Dev/dc/deucescracked/vendor/plugins/cache_money/lib/cash/query/abstract.rb:65:in `hit_or_miss' from /Users/wiseleyb/Dev/dc/deucescracked/vendor/plugins/cache_money/lib/cash/query/abstract.rb:18:in `perform' from /Users/wiseleyb/Dev/dc/deucescracked/vendor/plugins/cache_money/lib/cash/query/primary_key.rb:17:in `perform' from /Users/wiseleyb/Dev/dc/deucescracked/vendor/plugins/cache_money/lib/cash/query/abstract.rb:7:in `perform' from /Users/wiseleyb/Dev/dc/deucescracked/vendor/plugins/cache_money/lib/cash/finders.rb:29:in `find_from_ids' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/base.rb:616:in `find'If I do BlogEntry.find_by_id(2) first, then BlogEntry.find(2) works (after it's been stored in memcache.
Comments
-
repository delegated to @cache_config.repository, but @cache_config is nil
4 comments Created 2 months ago by ponnyI've tried getting backgroundrb and background-fu going. Cache money seems to be getting in the way somehow -
/var/lib/gems/1.8/gems/nkallen-cache-money-0.2.5/lib/cash/config.rb:18:in `repository': repository delegated to @cache_config.repository, but @cache_config is nil: BdrbJobQueue(id: integer, args: binary, worker_name: string, worker_method: string, job_key: string, taken: integer, finished: integer, timeout: integer, priority: integer, submitted_at: datetime, started_at: datetime, finished_at: datetime, archived_at: datetime, tag: string, submitter_info: string, runner_info: string, worker_key: string, scheduled_at: datetime) (RuntimeError)It did the same thing for background-fu's Job model too. I have absolutely no idea what is wrong with it.
Comments
I found a solution for this issue.
The thing is cache-money config file is loading after acts_as_taggable gem.
So I placed
"require File.join(RAILS_ROOT, "config", "initializers","cache_money.rb")" to begin of acts_as_taggable main file (lib/acts-as-taggable-on.rb) and it works!
krishnasrihari
Tue Dec 01 06:48:35 -0800 2009
| link
I have same problem and solved because I am using active_record session store. Now I changed to memcached store as config.action_controller.session_store = :mem_cache_store in environment.rb file and working fine now.
-
Please replace those requirements with 'active_record' and 'active_support'. They are deprecated from Rails 2.3.5.
Comments
-
Is it possible to avoid caching if memcached is down without raising an error?
Comments












Has there been any other fix for this? I tried this fix out and found that it ended up meaning nothing would end up getting cached...
Sorry, I didn't update. We found the fix didn't work out. We ended up moving the Locale classes to the model. There is really no other way of fixing this.
Do you mean you moved the file that defined Locale to app/models out of vendor? Did you still have to make the change in the code?
Or do you mean you had to take the code in the Locale plugin and put it directly into any of the models that were going to use it?
Think I found the fix:
in abstract.rb:
That could do it. We just moved the locale.rb file to our models directory.
That worked for me!!! for an unknown reason, this ticket's info is not easily found via a google search of the error. It would be great to integrate it into the main rep.
Committed it to my fork.