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

Already on GitHub? Sign in to your account

Activerecord cache key as timestamp #5844

Closed
wants to merge 597 commits into
from

Conversation

Projects
None yet

Cache key for ActiveRecord model is calculated using to_s(:number) method on updated_at timestamp.

This approach rounds the cache_key to whole number of seconds. If record is changed twice within a second, later change wont change the cache_key, which leads to inconsistent state.

Common example would be user accidentally clicking twice on an ajaxified link with some kind of toggle behavior. Even though it will toggle it twice, cache will change only once.

I changed the cache_key to include float timestamp rather than :number representation of time.

josevalim and others added some commits Feb 13, 2012

@josevalim josevalim Fix deprecation warning in AS::Concern. 305d5d5
@josevalim @josevalim josevalim Merge pull request #5038 from carlosantoniodasilva/fix-db-migrate-redo
Always reenable _dump task in AR databases rake. Closes #5030
5f9a5a5
@spastorino spastorino Rack body respond to each and not to join
This fixes undef `to_str' for Rack::Chunked::Body when using
caches_action + streaming on an action

Closes #5027
7c79996
@tenderlove tenderlove adding tests to document behavior for #4817 201e67e
@josevalim @josevalim josevalim Merge pull request #5049 from fabioyamate/master
Fix sanitize_for_mass_assigment when role is nil
a1b9acb
@arunagw arunagw Fixes failing test with ruby 1.8.7-p358
Same as 91a9b24
c17608f
Aditya Sanghi backporting #4918 to 3.2 stable; adding extra test for accept header …
…given by googlebot
dffd85a
@josevalim josevalim Merge pull request #5073 from asanghi/4918_backport
Backporting #4918 with one added test for googlebot accept header as I saw it
45503ec
@spastorino spastorino Merge pull request #5071 from arunagw/fix_failing_test_ruby187_p358
Fix failing test ruby187 p358
1a0bc2a
@pixeltrix pixeltrix Fix ActionDispatch::Static to serve files with unencoded PCHAR
RFC 3986[1] allows sub-delim characters in path segments unencoded,
however Rack::File requires them to be encoded so we use URI's
unescape method to leave them alone and then escape them again.

Also since the path gets passed to Dir[] we need to escape any glob
characters in the path.

[1]: http://www.ietf.org/rfc/rfc3986.txt
86d3bc3
@pixeltrix pixeltrix Simplify regexp 1b4e6ca
@arunagw arunagw fix test with ruby 187-p358 742b615
@fxn fxn Merge pull request #5081 from arunagw/fix_ar_test
Fix ar test
3b61efc
@lest @vijaydev lest fix spacer template example ed3a15d
@oestrich @vijaydev oestrich Update Time#change docs to reflect the options it uses
[ci skip]
ea54d2c
@avakhov @vijaydev avakhov Fix actionpack readme weblog example 168e653
@ffmike @vijaydev ffmike Documenting the :inverse_of option for associations 44849b1
@vijaydev vijaydev fix a typo [ci skip] b2e9bbd
@pwnall pwnall Removed (outdated?) config.action_view.logger from configuration guide. 64fa7f7
@pixeltrix pixeltrix Remove fixture files with Windows incompatible filenames
Windows doesn't allow `\ / : * ? " < > |` in filenames so create
the fixture files at runtime and ignore the incompatible ones when
running on Windows.
41c182c
@funny-falcon @tenderlove funny-falcon sync __run_callbacks with ruby-trunk
https://bugs.ruby-lang.org/projects/ruby-trunk/repository/revisions/34580
In this revision behavior of respond_to? had changed: now to ask about
protected method one should pass second argument `true`
0c0f278
@tenderlove tenderlove search private / protected methods in trunk ruby 3b824d6
@ckdake ckdake Reset memoized hash keys when new entry added 68d3a46
@josevalim josevalim Merge pull request #5101 from ckdake/ckdake_actionview_handler_reset
Reset memoized hash keys when new ActionView::Template handler is registered
8c870f1
@spastorino spastorino Use the right format when a partial is missing.
Closes #5025
8b86259
@spastorino spastorino Fix a failing test b80d8f7
@lest @tenderlove lest fix output safety issue with select options 7b73913
@amatsuda @tenderlove amatsuda add AS::SafeBuffer#clone_empty 621d219
@amatsuda @tenderlove amatsuda use AS::SafeBuffer#clone_empty for flushing the output_buffer 42fabd2
@amatsuda @tenderlove amatsuda delete vulnerable AS::SafeBuffer#[] dfa33fa
@kennyj kennyj Fix some warnings on 3-2-stable 39d4617
@spastorino spastorino Merge pull request #5106 from kennyj/fix_warnings_20120210
[3-2-stable] Fix some warnings
c426591
@spastorino spastorino Add CHANGELOG entry b122968
@spastorino spastorino Restore lookup formats to the previous value after searching for the …
…failing view
4eff6bc
@tenderlove tenderlove Merge pull request #5096 from lawso017/master
Restoring ability to derive id/sequence from tables with nonstandard sequences for primary keys
d70ed10
@spastorino spastorino Don't wrap the raise with ensure f92c812
@vijaydev vijaydev fix bad docs from f373f29 [ci skip] cc848d6
@tenderlove tenderlove ruby 2.0 makes protected methods return false for respond_to, so pass…
… true as the second param
0052d90
@tenderlove tenderlove more ruby 2.0 respond_to? changes c73f883
@tenderlove tenderlove tag bind params with a bind param object a566ee5
@tenderlove tenderlove prepared statements can be disabled 83e42d5
@tenderlove tenderlove bumping up arel 35626fe
@spastorino spastorino format lookup for partials is derived from the format in which the te…
…mplate is being rendered


Closes #5025 part 2
19433ce
@spastorino spastorino Add CHANGELOG entry 110b43c
@spastorino spastorino Fix CHANGELOG 82d6ded
@tenderlove tenderlove updating RAILS_VERSION 4bcd437
@tenderlove tenderlove Merge pull request #5084 from johndouthat/patch-1
Remove reference to rails_legacy_mapper, which isn't compatible with 3.2...
fadad9f
@tenderlove tenderlove Merge pull request #5084 from johndouthat/patch-1
Remove reference to rails_legacy_mapper, which isn't compatible with 3.2...
93f1667
@tenderlove tenderlove Merge pull request #5087 from pwnall/no_view_logger
Remove reference to config.action_view.logger from Rails configuration guide
c5c3274
@josevalim josevalim Avoid inspecting the whole route set, closes #1525 419040f
@tenderlove tenderlove Merge pull request #4834 from sskirby/fix_usage_of_psql_in_db_test_pr…
…epare

Fix usage of psql in db:test:prepare
6dbf6f3
@tenderlove tenderlove Merge pull request #4834 from sskirby/fix_usage_of_psql_in_db_test_pr…
…epare

Fix usage of psql in db:test:prepare
ecff25c
@arunagw arunagw Build fix for ruby187-p358 99fa8e5
@fxn fxn Merge pull request #5164 from arunagw/build_fix_ruby187-p358
Build fix ruby187 p358
5661dab
@arunagw arunagw Checking headers in a better way. as doing here 0bfcd4f
@fxn fxn Merge pull request #5166 from arunagw/3-2-stable
3 2 stable
8125304
@arunagw arunagw assert => assert_equal a9b1397
@spastorino spastorino Merge pull request #5170 from arunagw/3-2-stable
assert => assert_equal
0a1357b
@noahhendrix @vijaydev noahhendrix Fixed typo in composed_of example with Money#<=>, was comparing amoun…
…t itself instead of other_money.amount
e1f799a
@glitterfang @vijaydev glitterfang Fix typo in match :to docs b229bc7

What's the sense of this code? I know that's how it used to be, I'm just curious, maybe it didn't make sense before. It seems to me that it's deleting a value from a hash and immediately assigning it back under the same key.

On a side note, what's the rationale behind not including authenticity_token for AJAX forms? If it doesn't hurt, maybe it doesn't make sense to have this conditional, and an extra config option, and another option for form_for.

Member

drogus replied Mar 28, 2012

On a side note, what's the rationale behind not including authenticity_token for AJAX forms?
If it doesn't hurt, maybe it doesn't make sense to have this conditional, and an extra config
option, and another option for form_for.

It can hurt if you cache the form. If you use ajax only you will get auth token from meta tags anyway, so it matters only if you want to also handle the form without javascript. also, see this: d646d9d

Contributor

exviva replied Mar 28, 2012

Don't the UJS drivers override the authenticity_token hidden input's value with the meta tag's value anyway?

I was referring to your commit when mentioning the extra config option. All in all, I'm still trying to fully understand this change - thanks for the information.

Member

drogus replied Mar 28, 2012

Don't the UJS drivers override the authenticity_token hidden input's value with the meta tag's value anyway?

Frankly, I'm not sure :)

Member

drogus replied Mar 28, 2012

But even if yes, you don't necessarily need to use UJS drivers. We can't rely on it.

drogus added some commits Mar 28, 2012

@drogus drogus Cover one more case in auth_token and remote forms
If embedding auth_token in remote forms is off and we
pass a value for auth_token it should respect it.
d5980b5
@drogus drogus Cover one more case in auth_token and remote forms
If embedding auth_token in remote forms is off and we
pass a value for auth_token it should respect it.
db2c135
Contributor

khustochka commented on d646d9d Mar 28, 2012

Am I right this only goes to 3.2-stable but not to master?

Member

drogus replied Mar 28, 2012

@khustochka it goes also to master, but will be set to false by default.

Contributor

khustochka replied Mar 28, 2012

@drogus thanks

yahonda and others added some commits Mar 28, 2012

@yahonda yahonda Change the order argument from ('id') to ('taggings.id')
to address ORA-00918 error
ef3f809
@spastorino spastorino Merge pull request #5640 from yahonda/address_ora_00918_with_oracle
Address an error for test_has_many_through_polymorphic_has_one with Oracle
f369f77
@spastorino spastorino Set proper rendered_format when doing render :inline
Closes #5632
5747e53
@spastorino spastorino Set proper rendered_format when doing render :inline
Closes #5632
87825a6
@andhapp andhapp Changed the config.assets.manifest to nil in the comments in the prod…
…uction config template.
a157d59
@spastorino spastorino Merge pull request #5644 from andhapp/fix-config-asset-manifest-3-2
Changed the config.assets.manifest to nil
2b2a760
@vijaydev vijaydev fix incorrect url in the deprecation message for vendor/plugins [ci s…
…kip]
1d753ab
@vijaydev @spastorino vijaydev fix incorrect url in the deprecation message for vendor/plugins [ci s…
…kip]
921c404
@spastorino spastorino Add missing CHANGELOG entry dd69076
@spastorino spastorino Add missing CHANGELOG entry b395ca1
@spastorino spastorino Bumping to 3.2.3.rc2 5284e65
@arturopie arturopie Adds a test that breaks IM when using #select b29e868
@arturopie arturopie Do not add record to identity map if the record doesn't have values f…
…or all the columns, so we don't get 'MissingAttributeError' later when trying to access other fields of the same record.
2c8f84d
@arturopie arturopie refactor the checking of the attributes of the record in IdentityMap#…
…add, so it's more readable
714a2c8
@arturopie arturopie refactor instantiate method in base, so we remove nesting if's which …
…make the code harder to read. Minor changes to contain_all_columns in IdentityMap.

Conflicts:

	activerecord/lib/active_record/base.rb
6896cd4
@spastorino spastorino Remove the leading \n added by textarea on assert_select 13fe190
@spastorino spastorino Remove the leading \n added by textarea on assert_select 5c7bb86
@jonleighton jonleighton Fix #5667. Preloading should ignore scoping.
Conflicts:

	activerecord/test/cases/associations/eager_test.rb
dffbb52

+1 to this. This is also problematic on old tables that were designed for HABTM relationships.

spastorino and others added some commits Mar 30, 2012

@spastorino spastorino Bump up to 3.2.3 45d6cd9
@spastorino spastorino Merge branch '3-2-3' into 3-2-stable 69465d9
@tenderlove tenderlove Merge pull request #5662 from arturopie/3-2_fixing_IM_when_using_find…
…_select

Fixing Identity Map when using find select in rails 3.2
9894d16
@rafaelfranca @drogus rafaelfranca Fix the redirect when it receive blocks with arity of 1.
Closes #5677
27fc6ec
@drogus drogus Usage file in generators shouldn't be fetched only based on source_root
In case `source_roout` is not set, `default_source_root` is used,
which includes also `templates` directory. If there is no `templates`
directory, `default_source_root` is not available and USAGE will not
be displayed. USAGE should be also checked based on default
directory excluding `templates`.
515e1d3
Contributor

parndt commented on a7a422e Apr 2, 2012

Possible regression in resolve/refinerycms-blog#216 ?

Contributor

jcoleman replied Apr 2, 2012

Commented on refinery cms issue.

tpope and others added some commits Apr 3, 2012

@tpope @tenderlove tpope DATABASE_URL allows omission of database.yml 8e315b0
@kevmoo kevmoo Remove unused 'cast_code' variable 6f19262
@hone hone test initializer logic for DATABASE_URL env var 93f25ac
@hone hone log which config format AR uses to connect with d46ad34
@tenderlove tenderlove Merge pull request #5727 from hone/ar_database_url_logging
ActiveRecord configuration logging
c4d3102
@spastorino spastorino Merge pull request #5188 from jlxw/patch-1
logger.silence is deprecated
6663dd0
@rafaelfranca rafaelfranca Fix tests of benchmark with silence equals to true 1124ac0
@spastorino spastorino Merge pull request #5737 from rafaelfranca/3-2-stable
Fix tests of benchmark with silence equals to true
56d9945
@anildigital anildigital Fix Rails version in getting started guide. 1cd939a
@vijaydev vijaydev Merge pull request #5765 from anildigital/3-2-stable
Update getting started guide to change Rails version to Rails 3.2
bfd5c84
@anildigital @vijaydev anildigital Fix 'Everyday Git' link 05d4ccf
@rafaelfranca rafaelfranca default_url_options does not receive one argument anymore 5c7bcfc
@rafaelfranca rafaelfranca Document that default_url_options must return a hash with symbolized
keys
6f4f499
@spastorino spastorino Merge pull request #5784 from rafaelfranca/default_url-3-2
[3-2-stable] Document that default_url_options must return a hash with symbolized keys
e7671b5
@fxn fxn rewords the section about default_url_options in the Action Controlle…
…r Overview guide
b125db8
@fxn fxn Merge pull request #5725 from kevmoo/remove_unused_castcode
Remove unused castcode
dab76b1
@arunagw arunagw README fix! [skip ci] b1c28d7
@vijaydev vijaydev Merge pull request #5799 from arunagw/readme_fix
Readme fix
a85ffd0
@tenderlove @arunagw tenderlove add the class name to the assertion message ca0c0a2
@tenderlove @arunagw tenderlove bigdecimal can be duped on Ruby 2.0
Conflicts:

	activesupport/test/core_ext/duplicable_test.rb
2991370
@tenderlove @arunagw tenderlove probably should require the objects we monkey patch. fedd87c
@jeremy jeremy Merge pull request #5800 from arunagw/bigdecimal_dup
Backport BigDecimal#duplicable? feature check from master
e0fd4fc
@tenderlove @arunagw tenderlove test against ruby features in order to fix tests on Ruby 2.0 96d81e5
@jeremy jeremy Merge pull request #5820 from arunagw/more_ruby-2-0-fixes
Update test for Ruby 2 compatibility
e473e1f
@sikachu @vijaydev sikachu Fix code example in generator test case c0e6a85
@vijaydev vijaydev fix typo in readme [ci skip] efa9a1f
@alekseykulikov @drogus alekseykulikov "rails new -h" shows message in rails directory 2f9fdbf
@assembler assembler changed the way cache_key is generated from timestamp for ActiveRecor…
…d model
0c72b15

@assembler assembler closed this Apr 14, 2012

(people/5-1334398193.832774) add a dot notation on the url could be routed as a format ?

Owner

assembler replied Apr 15, 2012

ugh.. i was using this with memcached. dont know if it would cause any issues with other cache stores..?

@tenderlove this is prob a dumb question, but just wanted to make sure that shift is intended for binds and not *binds? I noticed just now that this to_sql method will alter the binds param for anything that uses binds after this is called.

Owner

tenderlove replied May 2, 2012

yes, the shift is indented for binds. Binds is a list of tuples, so the * is for expanding the tuple for the quote method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment