find_cache 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/{CHANGE-LOG → CHANGE_LOG.rdoc} +18 -13
- data/Gemfile +4 -0
- data/README.rdoc +5 -47
- data/Rakefile +4 -36
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/find_cache.gemspec +29 -0
- data/lib/find_cache.rb +6 -1
- data/lib/find_cache/cacheable.rb +37 -12
- data/lib/find_cache/controller_garbage_collector.rb +17 -0
- data/lib/find_cache/counter_cache.rb +14 -0
- data/lib/find_cache/key_gen.rb +10 -6
- data/lib/find_cache/version.rb +1 -1
- metadata +93 -328
- data/MIT-LICENSE +0 -22
- data/lib/tasks/find_cache_tasks.rake +0 -4
- data/test/dummy/README.rdoc +0 -261
- data/test/dummy/Rakefile +0 -7
- data/test/dummy/app/assets/javascripts/application.js +0 -15
- data/test/dummy/app/assets/stylesheets/application.css +0 -13
- data/test/dummy/app/controllers/application_controller.rb +0 -3
- data/test/dummy/app/helpers/application_helper.rb +0 -2
- data/test/dummy/app/models/comment.rb +0 -6
- data/test/dummy/app/models/post.rb +0 -7
- data/test/dummy/app/models/user.rb +0 -13
- data/test/dummy/app/views/layouts/application.html.erb +0 -14
- data/test/dummy/config.ru +0 -4
- data/test/dummy/config/application.rb +0 -59
- data/test/dummy/config/boot.rb +0 -10
- data/test/dummy/config/database.yml +0 -25
- data/test/dummy/config/environment.rb +0 -5
- data/test/dummy/config/environments/development.rb +0 -39
- data/test/dummy/config/environments/production.rb +0 -67
- data/test/dummy/config/environments/test.rb +0 -40
- data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/test/dummy/config/initializers/counter_cache_patch.rb +0 -19
- data/test/dummy/config/initializers/inflections.rb +0 -15
- data/test/dummy/config/initializers/mime_types.rb +0 -5
- data/test/dummy/config/initializers/secret_token.rb +0 -7
- data/test/dummy/config/initializers/session_store.rb +0 -8
- data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/test/dummy/config/locales/en.yml +0 -5
- data/test/dummy/config/routes.rb +0 -58
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/migrate/20120824210455_create_users.rb +0 -10
- data/test/dummy/db/migrate/20120824210731_create_comments.rb +0 -11
- data/test/dummy/db/migrate/20120824210927_create_posts.rb +0 -13
- data/test/dummy/db/schema.rb +0 -43
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/test.log +0 -1793
- data/test/dummy/public/404.html +0 -26
- data/test/dummy/public/422.html +0 -26
- data/test/dummy/public/500.html +0 -25
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +0 -6
- data/test/dummy/test/fixtures/comments.yml +0 -9
- data/test/dummy/test/fixtures/posts.yml +0 -13
- data/test/dummy/test/fixtures/users.yml +0 -9
- data/test/dummy/test/unit/comment_test.rb +0 -7
- data/test/dummy/test/unit/post_test.rb +0 -7
- data/test/dummy/test/unit/user_test.rb +0 -7
- data/test/dummy/tmp/cache/26E/540/User%2F1 +0 -0
- data/test/dummy/tmp/cache/26F/550/User%2F2 +0 -0
- data/test/dummy/tmp/cache/270/560/User%2F3 +0 -0
- data/test/dummy/tmp/cache/271/570/User%2F4 +0 -0
- data/test/dummy/tmp/cache/272/580/User%2F5 +0 -0
- data/test/dummy/tmp/cache/273/590/User%2F6 +0 -0
- data/test/dummy/tmp/cache/274/5A0/User%2F7 +0 -0
- data/test/dummy/tmp/cache/275/5B0/User%2F8 +0 -0
- data/test/dummy/tmp/cache/275/6E0/Post%2F1 +0 -0
- data/test/dummy/tmp/cache/276/5C0/User%2F9 +0 -0
- data/test/dummy/tmp/cache/276/6F0/Post%2F2 +0 -0
- data/test/dummy/tmp/cache/277/700/Post%2F3 +0 -0
- data/test/dummy/tmp/cache/29E/F20/User%2F10 +0 -0
- data/test/dummy/tmp/cache/29F/F30/User%2F11 +0 -0
- data/test/dummy/tmp/cache/29F/F40/User%2F20 +0 -0
- data/test/dummy/tmp/cache/2A0/F40/User%2F12 +0 -0
- data/test/dummy/tmp/cache/2A1/F50/User%2F13 +0 -0
- data/test/dummy/tmp/cache/2A2/F60/User%2F14 +0 -0
- data/test/dummy/tmp/cache/2A3/F70/User%2F15 +0 -0
- data/test/dummy/tmp/cache/2A4/F80/User%2F16 +0 -0
- data/test/dummy/tmp/cache/2A5/F90/User%2F17 +0 -0
- data/test/dummy/tmp/cache/2A6/FA0/User%2F18 +0 -0
- data/test/dummy/tmp/cache/2A7/FB0/User%2F19 +0 -0
- data/test/dummy/tmp/cache/3A8/070/Comment%2F7 +0 -0
- data/test/dummy/tmp/cache/3A9/080/Comment%2F8 +0 -0
- data/test/dummy/tmp/cache/3AA/090/Comment%2F9 +0 -0
- data/test/dummy/tmp/cache/3D2/D30/Comment%2F10 +0 -0
- data/test/dummy/tmp/cache/3D3/D50/Comment%2F20 +0 -0
- data/test/dummy/tmp/cache/3D4/D50/Comment%2F12 +0 -0
- data/test/dummy/tmp/cache/3D4/D70/Comment%2F30 +0 -0
- data/test/dummy/tmp/cache/3D5/D60/Comment%2F13 +0 -0
- data/test/dummy/tmp/cache/3D5/D70/Comment%2F22 +0 -0
- data/test/dummy/tmp/cache/3D5/D90/Comment%2F40 +0 -0
- data/test/dummy/tmp/cache/3D6/D70/Comment%2F14 +0 -0
- data/test/dummy/tmp/cache/3D6/D80/Comment%2F23 +0 -0
- data/test/dummy/tmp/cache/3D6/D90/Comment%2F32 +0 -0
- data/test/dummy/tmp/cache/3D6/DB0/Comment%2F50 +0 -0
- data/test/dummy/tmp/cache/3D7/D80/Comment%2F15 +0 -0
- data/test/dummy/tmp/cache/3D7/D90/Comment%2F24 +0 -0
- data/test/dummy/tmp/cache/3D7/DA0/Comment%2F33 +0 -0
- data/test/dummy/tmp/cache/3D7/DB0/Comment%2F42 +0 -0
- data/test/dummy/tmp/cache/3D7/DD0/Comment%2F60 +0 -0
- data/test/dummy/tmp/cache/3D8/DA0/Comment%2F25 +0 -0
- data/test/dummy/tmp/cache/3D8/DB0/Comment%2F34 +0 -0
- data/test/dummy/tmp/cache/3D8/DC0/Comment%2F43 +0 -0
- data/test/dummy/tmp/cache/3D8/DD0/Comment%2F52 +0 -0
- data/test/dummy/tmp/cache/3D8/DF0/Comment%2F70 +0 -0
- data/test/dummy/tmp/cache/3D9/DA0/Comment%2F17 +0 -0
- data/test/dummy/tmp/cache/3D9/DC0/Comment%2F35 +0 -0
- data/test/dummy/tmp/cache/3D9/DD0/Comment%2F44 +0 -0
- data/test/dummy/tmp/cache/3D9/DE0/Comment%2F53 +0 -0
- data/test/dummy/tmp/cache/3D9/DF0/Comment%2F62 +0 -0
- data/test/dummy/tmp/cache/3D9/E10/Comment%2F80 +0 -0
- data/test/dummy/tmp/cache/3DA/DB0/Comment%2F18 +0 -0
- data/test/dummy/tmp/cache/3DA/DC0/Comment%2F27 +0 -0
- data/test/dummy/tmp/cache/3DA/DE0/Comment%2F45 +0 -0
- data/test/dummy/tmp/cache/3DA/DF0/Comment%2F54 +0 -0
- data/test/dummy/tmp/cache/3DA/E00/Comment%2F63 +0 -0
- data/test/dummy/tmp/cache/3DA/E10/Comment%2F72 +0 -0
- data/test/dummy/tmp/cache/3DB/DC0/Comment%2F19 +0 -0
- data/test/dummy/tmp/cache/3DB/DD0/Comment%2F28 +0 -0
- data/test/dummy/tmp/cache/3DB/DE0/Comment%2F37 +0 -0
- data/test/dummy/tmp/cache/3DB/E00/Comment%2F55 +0 -0
- data/test/dummy/tmp/cache/3DB/E10/Comment%2F64 +0 -0
- data/test/dummy/tmp/cache/3DB/E20/Comment%2F73 +0 -0
- data/test/dummy/tmp/cache/3DB/E30/Comment%2F82 +0 -0
- data/test/dummy/tmp/cache/3DC/DE0/Comment%2F29 +0 -0
- data/test/dummy/tmp/cache/3DC/DF0/Comment%2F38 +0 -0
- data/test/dummy/tmp/cache/3DC/E00/Comment%2F47 +0 -0
- data/test/dummy/tmp/cache/3DC/E20/Comment%2F65 +0 -0
- data/test/dummy/tmp/cache/3DC/E30/Comment%2F74 +0 -0
- data/test/dummy/tmp/cache/3DC/E40/Comment%2F83 +0 -0
- data/test/dummy/tmp/cache/3DD/E00/Comment%2F39 +0 -0
- data/test/dummy/tmp/cache/3DD/E10/Comment%2F48 +0 -0
- data/test/dummy/tmp/cache/3DD/E20/Comment%2F57 +0 -0
- data/test/dummy/tmp/cache/3DD/E40/Comment%2F75 +0 -0
- data/test/dummy/tmp/cache/3DD/E50/Comment%2F84 +0 -0
- data/test/dummy/tmp/cache/3DE/E20/Comment%2F49 +0 -0
- data/test/dummy/tmp/cache/3DE/E30/Comment%2F58 +0 -0
- data/test/dummy/tmp/cache/3DE/E40/Comment%2F67 +0 -0
- data/test/dummy/tmp/cache/3DE/E60/Comment%2F85 +0 -0
- data/test/dummy/tmp/cache/3DF/E40/Comment%2F59 +0 -0
- data/test/dummy/tmp/cache/3DF/E50/Comment%2F68 +0 -0
- data/test/dummy/tmp/cache/3DF/E60/Comment%2F77 +0 -0
- data/test/dummy/tmp/cache/3E0/E60/Comment%2F69 +0 -0
- data/test/dummy/tmp/cache/3E0/E70/Comment%2F78 +0 -0
- data/test/dummy/tmp/cache/3E1/E80/Comment%2F79 +0 -0
- data/test/dummy/tmp/cache/58D/B70/Post%2Fuser_id-1 +0 -1
- data/test/find_cache_test.rb +0 -57
- data/test/test_helper.rb +0 -16
data/test/dummy/public/404.html
DELETED
@@ -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>
|
data/test/dummy/public/422.html
DELETED
@@ -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>
|
data/test/dummy/public/500.html
DELETED
@@ -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
|
data/test/dummy/script/rails
DELETED
@@ -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'
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -1 +0,0 @@
|
|
1
|
-
o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1345845702.720623:@value" i
|
data/test/find_cache_test.rb
DELETED
@@ -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
|
data/test/test_helper.rb
DELETED
@@ -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
|