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

Cache keys doesnt match #16

Open
diabolus opened this issue Feb 24, 2011 · 4 comments
Open

Cache keys doesnt match #16

diabolus opened this issue Feb 24, 2011 · 4 comments

Comments

@diabolus
Copy link

I recently installed this branch and when i created a new dummy record like Book cache key setted like "Book:1/3" when i updated it a new cache key setted like "Book:1/id/3" and they doesnt match on show and update screens.plugin always call first created cache key "Book:1/3" and always same values comes up.

here is the record creation debug logs:

Started GET "/books/3" for 127.0.0.1 at 2011-02-24 12:34:00 +0200
Processing by BooksController#show as HTML
Parameters: {"id"=>"3"}
CACHE GET "Book:1/3"
Memcached get: "Book:1/3"
Memcached miss: "Book:1/3"
Book Load (0.3ms) SELECT books.* FROM books WHERE books.id = 3 LIMIT 1
CACHE ADD Book:1/3 = #<Book id: 3, title: "new book", author: "new book", created_at: "2011-02-24 10:34:00", updated_at: "2011-02-24 10:34:00"> (604800, )
Memcached add: "Book:1/3"
Memcached hit: "Book:1/3"
Rendered books/show.html.erb within layouts/application (2.7ms)
Completed 200 OK in 47ms (Views: 7.2ms | ActiveRecord: 0.3ms)

When i updated the record the following logs are coming:

Started POST "/books/3" for 127.0.0.1 at 2011-02-24 12:35:15 +0200
Processing by BooksController#update as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"Qq27y38shDTjz/CitfiZYYKePvR0HGTO1DK7rzh8fuA=", "book"=>{"title"=>"updated book", "author"=>"updated book"}, "commit"=>"Update Book", "id"=>"3"}
CACHE GET "Book:1/3"
Memcached get: "Book:1/3"
Memcached hit: "Book:1/3"
SQL (0.1ms) BEGIN
AREL (0.3ms) UPDATE books SET title = 'updated book', author = 'updated book', updated_at = '2011-02-24 10:35:15' WHERE books.id = 3
add_object_to_primary_key_cache: [["id", 3]] #<Book id: 3, title: "updated book", author: "updated book", created_at: "2011-02-24 10:34:00", updated_at: "2011-02-24 10:35:15">
SERIALIZE OBJECT: #<Book id: 3, title: "updated book", author: "updated book", created_at: "2011-02-24 10:34:00", updated_at: "2011-02-24 10:35:15">
CACHE SET Book:1/id/3 = #<Book id: 3, title: "updated book", author: "updated book", created_at: "2011-02-24 10:34:00", updated_at: "2011-02-24 10:35:15">
Memcached add: "lock/Book:1/id/3"
Memcached hit: "lock/Book:1/id/3"
Memcached set: "Book:1/id/3"
Memcached hit: "Book:1/id/3"
Memcached delete: "lock/Book:1/id/3"
Memcached hit: "lock/Book:1/id/3"
SQL (69.4ms) COMMIT
Redirected to http://0.0.0.0:3000/books/3
Completed 302 Found in 89ms

Started GET "/books/3" for 127.0.0.1 at 2011-02-24 12:35:15 +0200
Processing by BooksController#show as HTML
Parameters: {"id"=>"3"}
CACHE GET "Book:1/3"
Memcached get: "Book:1/3"
Memcached hit: "Book:1/3"
Rendered books/show.html.erb within layouts/application (33.6ms)
Completed 200 OK in 46ms (Views: 38.6ms | ActiveRecord: 0.0ms)

as you can see last call made with "Book:1/3" key and old value returned.

@ashleym1972
Copy link

Can you write a test case for this?

@diabolus
Copy link
Author

diabolus commented Mar 1, 2011

I'm on it now.I sent you a detailed mail for this testing issue. Thanks.
i gonna send test files ASAP.

@ashleym1972
Copy link

Cool.

@diabolus
Copy link
Author

diabolus commented Mar 3, 2011

There is a version problem on these branch.Test files are for Rails 2.I made some changes like RSpec.configure and do the tests.
Some of tests are failing.

vendor/plugins/cache-money/spec/cash$ rspec finders_spec.rb

Finished in 1.09 seconds
42 examples, 34 failures

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