db_memoize 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +0 -6
- data/lib/db_memoize.rb +0 -1
- data/lib/db_memoize/migrations.rb +0 -1
- data/lib/db_memoize/model.rb +1 -8
- data/lib/db_memoize/railtie.rb +0 -3
- data/lib/db_memoize/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 542f66f353af4205b3032b105e573b3eff743f9f
|
4
|
+
data.tar.gz: 354532e3ecb878b26a2d2a292a77cb98b81019b9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 24aa305e6dfba23e2d7a4a8afa806295d74c4e410ba65e57630bde988564272859df0a530e3e831146591a43ca8ff32c80e853cd0cb3c9c48ed8146d0536d502
|
7
|
+
data.tar.gz: 46a725d1f3b0bbd703979c718a89a44ee7cf79c2fd73b281585ec5e45b07d59f103469dd3f3c0c86909ad97b840fd6d1a3bd4f45fcde2c06fd0672561557bf76
|
data/README.md
CHANGED
@@ -94,12 +94,6 @@ DbMemoize by default will write log output to STDOUT. You can change this by set
|
|
94
94
|
DbMemoize.logger = your_logger
|
95
95
|
```
|
96
96
|
|
97
|
-
To invalidate all cached keys easily you can specify a default custom key to be used internally like this:
|
98
|
-
|
99
|
-
```
|
100
|
-
DbMemoize.default_custom_key = 'e.g. latest git commit hash'
|
101
|
-
```
|
102
|
-
|
103
97
|
### Rake Tasks
|
104
98
|
|
105
99
|
To _warmup_ your cache you can pre-generate cached values via a rake task like this (only works for methods not depending on arguments)
|
data/lib/db_memoize.rb
CHANGED
data/lib/db_memoize/model.rb
CHANGED
@@ -38,10 +38,6 @@ module DbMemoize
|
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
|
-
def memoized_custom_key
|
42
|
-
::DbMemoize.default_custom_key
|
43
|
-
end
|
44
|
-
|
45
41
|
def memoize_values(values, *args)
|
46
42
|
args_hash = ::Digest::MD5.hexdigest(Marshal.dump(args))
|
47
43
|
|
@@ -57,7 +53,6 @@ module DbMemoize
|
|
57
53
|
entity_table_name: self.class.table_name,
|
58
54
|
method_name: method_name.to_s,
|
59
55
|
arguments_hash: args_hash,
|
60
|
-
custom_key: memoized_custom_key.to_s,
|
61
56
|
value: Marshal.dump(value)
|
62
57
|
)
|
63
58
|
end
|
@@ -65,8 +60,7 @@ module DbMemoize
|
|
65
60
|
def find_memoized_value(method_name, args_hash)
|
66
61
|
memoized_values.detect do |rec|
|
67
62
|
rec.method_name == method_name.to_s &&
|
68
|
-
rec.arguments_hash == args_hash
|
69
|
-
rec.custom_key == memoized_custom_key.to_s
|
63
|
+
rec.arguments_hash == args_hash
|
70
64
|
end
|
71
65
|
end
|
72
66
|
|
@@ -102,7 +96,6 @@ module DbMemoize
|
|
102
96
|
entity_id: id,
|
103
97
|
method_name: name,
|
104
98
|
arguments_hash: args_hash,
|
105
|
-
custom_key: DbMemoize.default_custom_key.to_s,
|
106
99
|
value: Marshal.dump(value)
|
107
100
|
)
|
108
101
|
end
|
data/lib/db_memoize/railtie.rb
CHANGED
@@ -2,9 +2,6 @@ module DbMemoize
|
|
2
2
|
class Railtie < ::Rails::Railtie
|
3
3
|
initializer 'Rails logger' do
|
4
4
|
DbMemoize.logger = Rails.logger
|
5
|
-
|
6
|
-
# by default invalidate cache when db schema has changed
|
7
|
-
DbMemoize.default_custom_key = ActiveRecord::Migrator.current_version
|
8
5
|
end
|
9
6
|
|
10
7
|
rake_tasks do
|
data/lib/db_memoize/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: db_memoize
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- johannes-kostas goetzinger
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-01-
|
11
|
+
date: 2017-01-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|