Skip to content

Cache keys doesnt match #16

@diabolus

Description

@diabolus

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions