forked from hooopo/second_level_cache
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
85 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,3 +1,7 @@ | |||
1.2.0 | 1.2.0 | ||
----- | ----- | ||
* [clear cache after update_counters](https://github.com/csdn-dev/second_level_cache/commit/240dde81199124092e0e8ad0500c167ac146e301) | * [clear cache after update_counters](https://github.com/csdn-dev/second_level_cache/commit/240dde81199124092e0e8ad0500c167ac146e301) | ||
|
|||
1.2.1 | |||
----- | |||
* [fix polymorphic association bug] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,36 +1,36 @@ | |||
PATH | PATH | ||
remote: . | remote: . | ||
specs: | specs: | ||
second_level_cache (1.1.1) | second_level_cache (1.2.1) | ||
activesupport (> 3.0) | activesupport (~> 3.2.0) | ||
|
|
||
GEM | GEM | ||
remote: http://rubygems.org/ | remote: http://rubygems.org/ | ||
specs: | specs: | ||
activemodel (3.2.1) | activemodel (3.2.6) | ||
activesupport (= 3.2.1) | activesupport (= 3.2.6) | ||
builder (~> 3.0.0) | builder (~> 3.0.0) | ||
activerecord (3.2.1) | activerecord (3.2.6) | ||
activemodel (= 3.2.1) | activemodel (= 3.2.6) | ||
activesupport (= 3.2.1) | activesupport (= 3.2.6) | ||
arel (~> 3.0.0) | arel (~> 3.0.2) | ||
tzinfo (~> 0.3.29) | tzinfo (~> 0.3.29) | ||
activesupport (3.2.1) | activesupport (3.2.6) | ||
i18n (~> 0.6) | i18n (~> 0.6) | ||
multi_json (~> 1.0) | multi_json (~> 1.0) | ||
arel (3.0.0) | arel (3.0.2) | ||
builder (3.0.0) | builder (3.0.0) | ||
i18n (0.6.0) | i18n (0.6.0) | ||
multi_json (1.0.4) | multi_json (1.3.6) | ||
rake (0.9.2.2) | rake (0.9.2.2) | ||
sqlite3 (1.3.5) | sqlite3 (1.3.6) | ||
tzinfo (0.3.31) | tzinfo (0.3.33) | ||
|
|
||
PLATFORMS | PLATFORMS | ||
ruby | ruby | ||
|
|
||
DEPENDENCIES | DEPENDENCIES | ||
activerecord (> 3.0) | activerecord (~> 3.2.0) | ||
rake | rake | ||
second_level_cache! | second_level_cache! | ||
sqlite3 | sqlite3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,2 +1,2 @@ | |||
# encoding: utf-8 | # -*- encoding : utf-8 -*- | ||
require File.expand_path("../lib/second_level_cache", __FILE__) | require File.expand_path("../lib/second_level_cache", __FILE__) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,4 +1,4 @@ | |||
# -*- encoding: utf-8 -*- | # -*- encoding : utf-8 -*- | ||
module SecondLevelCache | module SecondLevelCache | ||
VERSION = "1.2.0" | VERSION = "1.2.1" | ||
end | end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,11 +1,14 @@ | |||
# -*- encoding : utf-8 -*- | |||
ActiveRecord::Base.connection.create_table(:books, :force => true) do |t| | ActiveRecord::Base.connection.create_table(:books, :force => true) do |t| | ||
t.string :title | t.string :title | ||
t.string :body | t.string :body | ||
t.integer :user_id | t.integer :user_id | ||
t.integer :images_count, :default => 0 | |||
end | end | ||
|
|
||
class Book < ActiveRecord::Base | class Book < ActiveRecord::Base | ||
acts_as_cached | acts_as_cached | ||
|
|
||
belongs_to :user, :counter_cache => true | belongs_to :user, :counter_cache => true | ||
has_many :images, :as => :imagable | |||
end | end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,13 @@ | |||
# -*- encoding : utf-8 -*- | |||
ActiveRecord::Base.connection.create_table(:images, :force => true) do |t| | |||
t.string :url | |||
t.string :imagable_type | |||
t.integer :imagable_id | |||
end | |||
|
|||
class Image < ActiveRecord::Base | |||
acts_as_cached | |||
|
|||
belongs_to :imagable, :polymorphic => true, :counter_cache => true | |||
end | |||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,11 +1,14 @@ | |||
# -*- encoding : utf-8 -*- | |||
ActiveRecord::Base.connection.create_table(:users, :force => true) do |t| | ActiveRecord::Base.connection.create_table(:users, :force => true) do |t| | ||
t.string :name | t.string :name | ||
t.string :email | t.string :email | ||
t.integer :books_count, :default => 0 | t.integer :books_count, :default => 0 | ||
t.integer :images_count, :default => 0 | |||
end | end | ||
|
|
||
class User < ActiveRecord::Base | class User < ActiveRecord::Base | ||
acts_as_cached | acts_as_cached | ||
|
|
||
has_many :books | has_many :books | ||
has_many :images, :as => :imagable | |||
end | end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,24 @@ | |||
# -*- encoding : utf-8 -*- | |||
require 'active_record/test_helper' | |||
|
|||
class ActiveRecord::PolymorphicAssociationTest < Test::Unit::TestCase | |||
def setup | |||
@user = User.create :name => 'csdn', :email => 'test@csdn.com' | |||
end | |||
|
|||
def test_should_get_cache_when_use_polymorphic_association | |||
image = @user.images.create | |||
|
|||
no_connection do | |||
assert_equal @user, image.imagable | |||
end | |||
end | |||
|
|||
def test_should_write_polymorphic_association_cache | |||
image = @user.images.create | |||
@user.expire_second_level_cache | |||
assert_nil User.read_second_level_cache(@user.id) | |||
assert_equal @user, image.imagable | |||
end | |||
end | |||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters