cachers 4.0.0.0 → 4.1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cachers.rb +9 -0
- data/lib/cachers/base.rb +2 -9
- data/lib/cachers/concern.rb +14 -1
- data/lib/cachers/delegation.rb +17 -0
- data/lib/cachers/extensions/active_record/base.rb +20 -0
- data/lib/cachers/railtie.rb +10 -2
- data/lib/cachers/version.rb +1 -1
- data/lib/generators/{cacher → cachers/cacher}/cacher_generator.rb +2 -2
- data/lib/generators/{cacher → cachers/cacher}/templates/cacher.rb +0 -0
- data/lib/generators/cachers/install/install_generator.rb +15 -0
- data/lib/generators/cachers/install/templates/configuration.yml +15 -0
- data/test/dummy/app/cachers/user_cacher.rb +2 -2
- data/test/dummy/config/application.rb +0 -1
- data/test/dummy/config/database.yml +5 -2
- data/test/dummy/config/redis.yml +15 -0
- data/test/dummy/db/schema.rb +25 -0
- data/test/dummy/log/development.log +21 -0
- data/test/dummy/log/test.log +798 -0
- data/test/generator_test.rb +8 -1
- data/test/record_test.rb +5 -5
- data/test/task_test.rb +4 -4
- data/test/test_helper.rb +7 -0
- metadata +15 -7
- data/test/dummy/config/initializers/redis.rb +0 -1
data/test/generator_test.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
require 'rails/generators'
|
3
|
-
require 'generators/cacher/cacher_generator'
|
3
|
+
require 'generators/cachers/cacher/cacher_generator'
|
4
|
+
require 'generators/cachers/install/install_generator'
|
4
5
|
|
5
6
|
class GeneratorsTest < Rails::Generators::TestCase
|
6
7
|
destination Rails.root.join('tmp')
|
@@ -15,4 +16,10 @@ class GeneratorsTest < Rails::Generators::TestCase
|
|
15
16
|
assert_file 'app/cachers/user_cacher.rb'
|
16
17
|
end
|
17
18
|
|
19
|
+
test 'install' do
|
20
|
+
self.class.tests Cachers::Generators::InstallGenerator
|
21
|
+
run_generator
|
22
|
+
assert_file 'config/redis.yml'
|
23
|
+
end
|
24
|
+
|
18
25
|
end
|
data/test/record_test.rb
CHANGED
@@ -6,19 +6,19 @@ class RecordTest < ActiveSupport::TestCase
|
|
6
6
|
user = User.create(name: 'mike')
|
7
7
|
user.cache
|
8
8
|
key = "users/#{user.name}"
|
9
|
-
assert_equal user.id,
|
9
|
+
assert_equal user.id, client.get(key).to_i
|
10
10
|
|
11
11
|
user.update name: 'john'
|
12
12
|
old_key = key
|
13
13
|
key = "users/#{user.name}"
|
14
14
|
user.recache
|
15
|
-
assert_nil
|
16
|
-
assert_equal user.id,
|
15
|
+
assert_nil client.get(old_key)
|
16
|
+
assert_equal user.id, client.get(key).to_i
|
17
17
|
|
18
18
|
user.destroy
|
19
19
|
user.uncache
|
20
|
-
assert_nil
|
21
|
-
assert_nil
|
20
|
+
assert_nil client.get(old_key)
|
21
|
+
assert_nil client.get(key)
|
22
22
|
end
|
23
23
|
|
24
24
|
end
|
data/test/task_test.rb
CHANGED
@@ -15,21 +15,21 @@ class TaskTest < ActiveSupport::TestCase
|
|
15
15
|
Rake::Task['cachers:cache'].invoke
|
16
16
|
end
|
17
17
|
users.each do |user|
|
18
|
-
assert_equal user.id,
|
18
|
+
assert_equal user.id, client.get("users/#{user.name}").to_i
|
19
19
|
end
|
20
20
|
|
21
|
-
|
21
|
+
client.flushall
|
22
22
|
silence_stream(STDOUT) do
|
23
23
|
Rake::Task['cachers:recache'].invoke
|
24
24
|
end
|
25
25
|
users.each do |user|
|
26
|
-
assert_equal user.id,
|
26
|
+
assert_equal user.id, client.get("users/#{user.name}").to_i
|
27
27
|
end
|
28
28
|
|
29
29
|
silence_stream(STDOUT) do
|
30
30
|
Rake::Task['cachers:uncache'].invoke
|
31
31
|
end
|
32
|
-
assert_equal 0,
|
32
|
+
assert_equal 0, client.keys.size
|
33
33
|
end
|
34
34
|
|
35
35
|
end
|
data/test/test_helper.rb
CHANGED
@@ -11,3 +11,10 @@ Minitest.backtrace_filter = Minitest::BacktraceFilter.new
|
|
11
11
|
|
12
12
|
# Load support files
|
13
13
|
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
14
|
+
|
15
|
+
# Add client shortcut.
|
16
|
+
class ActiveSupport::TestCase
|
17
|
+
def client
|
18
|
+
Cachers.client
|
19
|
+
end
|
20
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cachers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- mmontossi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-12-
|
11
|
+
date: 2016-12-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -58,7 +58,7 @@ dependencies:
|
|
58
58
|
- - "~>"
|
59
59
|
- !ruby/object:Gem::Version
|
60
60
|
version: '3.2'
|
61
|
-
description: Dedicated classes to
|
61
|
+
description: Dedicated classes to isolate redis logic in rails.
|
62
62
|
email:
|
63
63
|
- mmontossi@gmail.com
|
64
64
|
executables: []
|
@@ -70,10 +70,14 @@ files:
|
|
70
70
|
- lib/cachers.rb
|
71
71
|
- lib/cachers/base.rb
|
72
72
|
- lib/cachers/concern.rb
|
73
|
+
- lib/cachers/delegation.rb
|
74
|
+
- lib/cachers/extensions/active_record/base.rb
|
73
75
|
- lib/cachers/railtie.rb
|
74
76
|
- lib/cachers/version.rb
|
75
|
-
- lib/generators/cacher/cacher_generator.rb
|
76
|
-
- lib/generators/cacher/templates/cacher.rb
|
77
|
+
- lib/generators/cachers/cacher/cacher_generator.rb
|
78
|
+
- lib/generators/cachers/cacher/templates/cacher.rb
|
79
|
+
- lib/generators/cachers/install/install_generator.rb
|
80
|
+
- lib/generators/cachers/install/templates/configuration.yml
|
77
81
|
- lib/tasks/cachers.rake
|
78
82
|
- test/dummy/Rakefile
|
79
83
|
- test/dummy/app/assets/javascripts/application.js
|
@@ -102,13 +106,15 @@ files:
|
|
102
106
|
- test/dummy/config/initializers/filter_parameter_logging.rb
|
103
107
|
- test/dummy/config/initializers/inflections.rb
|
104
108
|
- test/dummy/config/initializers/mime_types.rb
|
105
|
-
- test/dummy/config/initializers/redis.rb
|
106
109
|
- test/dummy/config/initializers/session_store.rb
|
107
110
|
- test/dummy/config/initializers/wrap_parameters.rb
|
108
111
|
- test/dummy/config/locales/en.yml
|
112
|
+
- test/dummy/config/redis.yml
|
109
113
|
- test/dummy/config/routes.rb
|
110
114
|
- test/dummy/config/secrets.yml
|
111
115
|
- test/dummy/db/migrate/20160918232127_create_users.rb
|
116
|
+
- test/dummy/db/schema.rb
|
117
|
+
- test/dummy/log/development.log
|
112
118
|
- test/dummy/log/test.log
|
113
119
|
- test/dummy/public/404.html
|
114
120
|
- test/dummy/public/422.html
|
@@ -168,14 +174,16 @@ test_files:
|
|
168
174
|
- test/dummy/config/initializers/filter_parameter_logging.rb
|
169
175
|
- test/dummy/config/initializers/inflections.rb
|
170
176
|
- test/dummy/config/initializers/mime_types.rb
|
171
|
-
- test/dummy/config/initializers/redis.rb
|
172
177
|
- test/dummy/config/initializers/session_store.rb
|
173
178
|
- test/dummy/config/initializers/wrap_parameters.rb
|
174
179
|
- test/dummy/config/locales/en.yml
|
180
|
+
- test/dummy/config/redis.yml
|
175
181
|
- test/dummy/config/routes.rb
|
176
182
|
- test/dummy/config/secrets.yml
|
177
183
|
- test/dummy/config.ru
|
178
184
|
- test/dummy/db/migrate/20160918232127_create_users.rb
|
185
|
+
- test/dummy/db/schema.rb
|
186
|
+
- test/dummy/log/development.log
|
179
187
|
- test/dummy/log/test.log
|
180
188
|
- test/dummy/public/404.html
|
181
189
|
- test/dummy/public/422.html
|
@@ -1 +0,0 @@
|
|
1
|
-
$redis = Redis.new(url: 'redis://localhost:6379/0')
|