find_cache 0.2.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (155) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +9 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +4 -0
  5. data/{CHANGE-LOG → CHANGE_LOG.rdoc} +18 -13
  6. data/Gemfile +4 -0
  7. data/README.rdoc +5 -47
  8. data/Rakefile +4 -36
  9. data/bin/console +14 -0
  10. data/bin/setup +7 -0
  11. data/find_cache.gemspec +29 -0
  12. data/lib/find_cache.rb +6 -1
  13. data/lib/find_cache/cacheable.rb +37 -12
  14. data/lib/find_cache/controller_garbage_collector.rb +17 -0
  15. data/lib/find_cache/counter_cache.rb +14 -0
  16. data/lib/find_cache/key_gen.rb +10 -6
  17. data/lib/find_cache/version.rb +1 -1
  18. metadata +93 -328
  19. data/MIT-LICENSE +0 -22
  20. data/lib/tasks/find_cache_tasks.rake +0 -4
  21. data/test/dummy/README.rdoc +0 -261
  22. data/test/dummy/Rakefile +0 -7
  23. data/test/dummy/app/assets/javascripts/application.js +0 -15
  24. data/test/dummy/app/assets/stylesheets/application.css +0 -13
  25. data/test/dummy/app/controllers/application_controller.rb +0 -3
  26. data/test/dummy/app/helpers/application_helper.rb +0 -2
  27. data/test/dummy/app/models/comment.rb +0 -6
  28. data/test/dummy/app/models/post.rb +0 -7
  29. data/test/dummy/app/models/user.rb +0 -13
  30. data/test/dummy/app/views/layouts/application.html.erb +0 -14
  31. data/test/dummy/config.ru +0 -4
  32. data/test/dummy/config/application.rb +0 -59
  33. data/test/dummy/config/boot.rb +0 -10
  34. data/test/dummy/config/database.yml +0 -25
  35. data/test/dummy/config/environment.rb +0 -5
  36. data/test/dummy/config/environments/development.rb +0 -39
  37. data/test/dummy/config/environments/production.rb +0 -67
  38. data/test/dummy/config/environments/test.rb +0 -40
  39. data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
  40. data/test/dummy/config/initializers/counter_cache_patch.rb +0 -19
  41. data/test/dummy/config/initializers/inflections.rb +0 -15
  42. data/test/dummy/config/initializers/mime_types.rb +0 -5
  43. data/test/dummy/config/initializers/secret_token.rb +0 -7
  44. data/test/dummy/config/initializers/session_store.rb +0 -8
  45. data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
  46. data/test/dummy/config/locales/en.yml +0 -5
  47. data/test/dummy/config/routes.rb +0 -58
  48. data/test/dummy/db/development.sqlite3 +0 -0
  49. data/test/dummy/db/migrate/20120824210455_create_users.rb +0 -10
  50. data/test/dummy/db/migrate/20120824210731_create_comments.rb +0 -11
  51. data/test/dummy/db/migrate/20120824210927_create_posts.rb +0 -13
  52. data/test/dummy/db/schema.rb +0 -43
  53. data/test/dummy/db/test.sqlite3 +0 -0
  54. data/test/dummy/log/test.log +0 -1793
  55. data/test/dummy/public/404.html +0 -26
  56. data/test/dummy/public/422.html +0 -26
  57. data/test/dummy/public/500.html +0 -25
  58. data/test/dummy/public/favicon.ico +0 -0
  59. data/test/dummy/script/rails +0 -6
  60. data/test/dummy/test/fixtures/comments.yml +0 -9
  61. data/test/dummy/test/fixtures/posts.yml +0 -13
  62. data/test/dummy/test/fixtures/users.yml +0 -9
  63. data/test/dummy/test/unit/comment_test.rb +0 -7
  64. data/test/dummy/test/unit/post_test.rb +0 -7
  65. data/test/dummy/test/unit/user_test.rb +0 -7
  66. data/test/dummy/tmp/cache/26E/540/User%2F1 +0 -0
  67. data/test/dummy/tmp/cache/26F/550/User%2F2 +0 -0
  68. data/test/dummy/tmp/cache/270/560/User%2F3 +0 -0
  69. data/test/dummy/tmp/cache/271/570/User%2F4 +0 -0
  70. data/test/dummy/tmp/cache/272/580/User%2F5 +0 -0
  71. data/test/dummy/tmp/cache/273/590/User%2F6 +0 -0
  72. data/test/dummy/tmp/cache/274/5A0/User%2F7 +0 -0
  73. data/test/dummy/tmp/cache/275/5B0/User%2F8 +0 -0
  74. data/test/dummy/tmp/cache/275/6E0/Post%2F1 +0 -0
  75. data/test/dummy/tmp/cache/276/5C0/User%2F9 +0 -0
  76. data/test/dummy/tmp/cache/276/6F0/Post%2F2 +0 -0
  77. data/test/dummy/tmp/cache/277/700/Post%2F3 +0 -0
  78. data/test/dummy/tmp/cache/29E/F20/User%2F10 +0 -0
  79. data/test/dummy/tmp/cache/29F/F30/User%2F11 +0 -0
  80. data/test/dummy/tmp/cache/29F/F40/User%2F20 +0 -0
  81. data/test/dummy/tmp/cache/2A0/F40/User%2F12 +0 -0
  82. data/test/dummy/tmp/cache/2A1/F50/User%2F13 +0 -0
  83. data/test/dummy/tmp/cache/2A2/F60/User%2F14 +0 -0
  84. data/test/dummy/tmp/cache/2A3/F70/User%2F15 +0 -0
  85. data/test/dummy/tmp/cache/2A4/F80/User%2F16 +0 -0
  86. data/test/dummy/tmp/cache/2A5/F90/User%2F17 +0 -0
  87. data/test/dummy/tmp/cache/2A6/FA0/User%2F18 +0 -0
  88. data/test/dummy/tmp/cache/2A7/FB0/User%2F19 +0 -0
  89. data/test/dummy/tmp/cache/3A8/070/Comment%2F7 +0 -0
  90. data/test/dummy/tmp/cache/3A9/080/Comment%2F8 +0 -0
  91. data/test/dummy/tmp/cache/3AA/090/Comment%2F9 +0 -0
  92. data/test/dummy/tmp/cache/3D2/D30/Comment%2F10 +0 -0
  93. data/test/dummy/tmp/cache/3D3/D50/Comment%2F20 +0 -0
  94. data/test/dummy/tmp/cache/3D4/D50/Comment%2F12 +0 -0
  95. data/test/dummy/tmp/cache/3D4/D70/Comment%2F30 +0 -0
  96. data/test/dummy/tmp/cache/3D5/D60/Comment%2F13 +0 -0
  97. data/test/dummy/tmp/cache/3D5/D70/Comment%2F22 +0 -0
  98. data/test/dummy/tmp/cache/3D5/D90/Comment%2F40 +0 -0
  99. data/test/dummy/tmp/cache/3D6/D70/Comment%2F14 +0 -0
  100. data/test/dummy/tmp/cache/3D6/D80/Comment%2F23 +0 -0
  101. data/test/dummy/tmp/cache/3D6/D90/Comment%2F32 +0 -0
  102. data/test/dummy/tmp/cache/3D6/DB0/Comment%2F50 +0 -0
  103. data/test/dummy/tmp/cache/3D7/D80/Comment%2F15 +0 -0
  104. data/test/dummy/tmp/cache/3D7/D90/Comment%2F24 +0 -0
  105. data/test/dummy/tmp/cache/3D7/DA0/Comment%2F33 +0 -0
  106. data/test/dummy/tmp/cache/3D7/DB0/Comment%2F42 +0 -0
  107. data/test/dummy/tmp/cache/3D7/DD0/Comment%2F60 +0 -0
  108. data/test/dummy/tmp/cache/3D8/DA0/Comment%2F25 +0 -0
  109. data/test/dummy/tmp/cache/3D8/DB0/Comment%2F34 +0 -0
  110. data/test/dummy/tmp/cache/3D8/DC0/Comment%2F43 +0 -0
  111. data/test/dummy/tmp/cache/3D8/DD0/Comment%2F52 +0 -0
  112. data/test/dummy/tmp/cache/3D8/DF0/Comment%2F70 +0 -0
  113. data/test/dummy/tmp/cache/3D9/DA0/Comment%2F17 +0 -0
  114. data/test/dummy/tmp/cache/3D9/DC0/Comment%2F35 +0 -0
  115. data/test/dummy/tmp/cache/3D9/DD0/Comment%2F44 +0 -0
  116. data/test/dummy/tmp/cache/3D9/DE0/Comment%2F53 +0 -0
  117. data/test/dummy/tmp/cache/3D9/DF0/Comment%2F62 +0 -0
  118. data/test/dummy/tmp/cache/3D9/E10/Comment%2F80 +0 -0
  119. data/test/dummy/tmp/cache/3DA/DB0/Comment%2F18 +0 -0
  120. data/test/dummy/tmp/cache/3DA/DC0/Comment%2F27 +0 -0
  121. data/test/dummy/tmp/cache/3DA/DE0/Comment%2F45 +0 -0
  122. data/test/dummy/tmp/cache/3DA/DF0/Comment%2F54 +0 -0
  123. data/test/dummy/tmp/cache/3DA/E00/Comment%2F63 +0 -0
  124. data/test/dummy/tmp/cache/3DA/E10/Comment%2F72 +0 -0
  125. data/test/dummy/tmp/cache/3DB/DC0/Comment%2F19 +0 -0
  126. data/test/dummy/tmp/cache/3DB/DD0/Comment%2F28 +0 -0
  127. data/test/dummy/tmp/cache/3DB/DE0/Comment%2F37 +0 -0
  128. data/test/dummy/tmp/cache/3DB/E00/Comment%2F55 +0 -0
  129. data/test/dummy/tmp/cache/3DB/E10/Comment%2F64 +0 -0
  130. data/test/dummy/tmp/cache/3DB/E20/Comment%2F73 +0 -0
  131. data/test/dummy/tmp/cache/3DB/E30/Comment%2F82 +0 -0
  132. data/test/dummy/tmp/cache/3DC/DE0/Comment%2F29 +0 -0
  133. data/test/dummy/tmp/cache/3DC/DF0/Comment%2F38 +0 -0
  134. data/test/dummy/tmp/cache/3DC/E00/Comment%2F47 +0 -0
  135. data/test/dummy/tmp/cache/3DC/E20/Comment%2F65 +0 -0
  136. data/test/dummy/tmp/cache/3DC/E30/Comment%2F74 +0 -0
  137. data/test/dummy/tmp/cache/3DC/E40/Comment%2F83 +0 -0
  138. data/test/dummy/tmp/cache/3DD/E00/Comment%2F39 +0 -0
  139. data/test/dummy/tmp/cache/3DD/E10/Comment%2F48 +0 -0
  140. data/test/dummy/tmp/cache/3DD/E20/Comment%2F57 +0 -0
  141. data/test/dummy/tmp/cache/3DD/E40/Comment%2F75 +0 -0
  142. data/test/dummy/tmp/cache/3DD/E50/Comment%2F84 +0 -0
  143. data/test/dummy/tmp/cache/3DE/E20/Comment%2F49 +0 -0
  144. data/test/dummy/tmp/cache/3DE/E30/Comment%2F58 +0 -0
  145. data/test/dummy/tmp/cache/3DE/E40/Comment%2F67 +0 -0
  146. data/test/dummy/tmp/cache/3DE/E60/Comment%2F85 +0 -0
  147. data/test/dummy/tmp/cache/3DF/E40/Comment%2F59 +0 -0
  148. data/test/dummy/tmp/cache/3DF/E50/Comment%2F68 +0 -0
  149. data/test/dummy/tmp/cache/3DF/E60/Comment%2F77 +0 -0
  150. data/test/dummy/tmp/cache/3E0/E60/Comment%2F69 +0 -0
  151. data/test/dummy/tmp/cache/3E0/E70/Comment%2F78 +0 -0
  152. data/test/dummy/tmp/cache/3E1/E80/Comment%2F79 +0 -0
  153. data/test/dummy/tmp/cache/58D/B70/Post%2Fuser_id-1 +0 -1
  154. data/test/find_cache_test.rb +0 -57
  155. data/test/test_helper.rb +0 -16
@@ -1,26 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>The page you were looking for doesn't exist (404)</title>
5
- <style type="text/css">
6
- body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
- div.dialog {
8
- width: 25em;
9
- padding: 0 4em;
10
- margin: 4em auto 0 auto;
11
- border: 1px solid #ccc;
12
- border-right-color: #999;
13
- border-bottom-color: #999;
14
- }
15
- h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
- </style>
17
- </head>
18
-
19
- <body>
20
- <!-- This file lives in public/404.html -->
21
- <div class="dialog">
22
- <h1>The page you were looking for doesn't exist.</h1>
23
- <p>You may have mistyped the address or the page may have moved.</p>
24
- </div>
25
- </body>
26
- </html>
@@ -1,26 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>The change you wanted was rejected (422)</title>
5
- <style type="text/css">
6
- body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
- div.dialog {
8
- width: 25em;
9
- padding: 0 4em;
10
- margin: 4em auto 0 auto;
11
- border: 1px solid #ccc;
12
- border-right-color: #999;
13
- border-bottom-color: #999;
14
- }
15
- h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
- </style>
17
- </head>
18
-
19
- <body>
20
- <!-- This file lives in public/422.html -->
21
- <div class="dialog">
22
- <h1>The change you wanted was rejected.</h1>
23
- <p>Maybe you tried to change something you didn't have access to.</p>
24
- </div>
25
- </body>
26
- </html>
@@ -1,25 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>We're sorry, but something went wrong (500)</title>
5
- <style type="text/css">
6
- body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
- div.dialog {
8
- width: 25em;
9
- padding: 0 4em;
10
- margin: 4em auto 0 auto;
11
- border: 1px solid #ccc;
12
- border-right-color: #999;
13
- border-bottom-color: #999;
14
- }
15
- h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
- </style>
17
- </head>
18
-
19
- <body>
20
- <!-- This file lives in public/500.html -->
21
- <div class="dialog">
22
- <h1>We're sorry, but something went wrong.</h1>
23
- </div>
24
- </body>
25
- </html>
File without changes
@@ -1,6 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
-
4
- APP_PATH = File.expand_path('../../config/application', __FILE__)
5
- require File.expand_path('../../config/boot', __FILE__)
6
- require 'rails/commands'
@@ -1,9 +0,0 @@
1
- # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
2
-
3
- one:
4
- post:
5
- content: MyText
6
-
7
- two:
8
- post:
9
- content: MyText
@@ -1,13 +0,0 @@
1
- # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
2
-
3
- one:
4
- user:
5
- title: MyString
6
- body: MyText
7
- comments_count: 1
8
-
9
- two:
10
- user:
11
- title: MyString
12
- body: MyText
13
- comments_count: 1
@@ -1,9 +0,0 @@
1
- # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
2
-
3
- one:
4
- email: MyString
5
- password: MyString
6
-
7
- two:
8
- email: MyString
9
- password: MyString
@@ -1,7 +0,0 @@
1
- require 'test_helper'
2
-
3
- class CommentTest < ActiveSupport::TestCase
4
- # test "the truth" do
5
- # assert true
6
- # end
7
- end
@@ -1,7 +0,0 @@
1
- require 'test_helper'
2
-
3
- class PostTest < ActiveSupport::TestCase
4
- # test "the truth" do
5
- # assert true
6
- # end
7
- end
@@ -1,7 +0,0 @@
1
- require 'test_helper'
2
-
3
- class UserTest < ActiveSupport::TestCase
4
- # test "the truth" do
5
- # assert true
6
- # end
7
- end
@@ -1 +0,0 @@
1
- o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1345845702.720623: @value" i
@@ -1,57 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- require 'test_helper'
3
-
4
- class FindCacheTest < Test::Unit::TestCase
5
-
6
- # record test
7
- def test_user_find_by_id_should_be_find_cache
8
- Rails.cache.clear
9
- user = User.create email: "test@videofork.com", password: "test1234"
10
- id = user.id
11
- assert_equal User.find_by_id(id), User.find_cache(id)
12
- end
13
-
14
- # find_cache_has_one test
15
- def test_user_post_should_be_user_post_cache
16
- Rails.cache.clear
17
- user = User.first
18
- assert_equal user.post, user.post_cache
19
- end
20
-
21
- # find_cache_belongs_to test
22
- def test_post_user_should_be_post_user_cache
23
- Rails.cache.clear
24
- post = Post.first
25
- assert_equal post.user, post.user_cache
26
- end
27
-
28
- # record update test
29
- def test_post_update_should_expire_the_post_cache
30
- Rails.cache.clear
31
- post = Post.first
32
- Post.find_cache(post.id) # to cache the post
33
- post.update_attributes(title: "test", body: "hello world!")
34
- assert_equal post, Post.find_cache(post.id)
35
- end
36
-
37
- # counter cache fix test
38
- def test_after_adding_comment_post_should_expire_the_post_cache
39
- Rails.cache.clear
40
- post = Post.first
41
- Post.find_cache(post.id) # to cache the post
42
- Comment.create post_id: post.id, content: "test content for comment"
43
- assert_equal Post.find_by_id(post.id), Post.find_cache(post.id)
44
- end
45
-
46
- # find_all_cache test
47
- def test_find_all_by_id_should_be_find_all_cache
48
- Rails.cache.clear
49
- c1 = Comment.create post_id: Post.first.id, content: "test 1 content for comment"
50
- c2 = Comment.create post_id: Post.first.id, content: "test 2 content for comment"
51
- c3 = Comment.create post_id: Post.first.id, content: "test 3 content for comment"
52
- c4 = Comment.create post_id: Post.first.id, content: "test 4 content for comment"
53
- ids = [c1.id, c2.id, c3.id, c4.id]
54
- assert_equal Comment.order("id ASC").find_all_by_id(ids), Comment.find_all_cache(ids, "id ASC")
55
- end
56
-
57
- end
@@ -1,16 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- # Configure Rails Environment
3
- ENV["RAILS_ENV"] = "test"
4
-
5
- require File.expand_path("../dummy/config/environment.rb", __FILE__)
6
- require "rails/test_help"
7
-
8
- Rails.backtrace_cleaner.remove_silencers!
9
-
10
- # Load support files
11
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
12
-
13
- # Load fixtures from the engine
14
- if ActiveSupport::TestCase.method_defined?(:fixture_path=)
15
- ActiveSupport::TestCase.fixture_path = File.expand_path("../fixtures", __FILE__)
16
- end