has_cache_key 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +6 -6
- data/lib/has_cache_key/model_ext.rb +2 -2
- data/lib/has_cache_key/possible_values.rb +1 -4
- data/lib/has_cache_key/version.rb +2 -2
- metadata +9 -9
data/README.md
CHANGED
@@ -25,14 +25,14 @@ Define cache_keys in your model
|
|
25
25
|
To get a cache key in you can use one of the following:
|
26
26
|
|
27
27
|
|
28
|
-
|
29
|
-
|
28
|
+
# Default cache key
|
29
|
+
@listing.cache_key
|
30
30
|
|
31
|
-
|
32
|
-
|
31
|
+
# A cache key
|
32
|
+
@listing.cache_key(:category_in_location_home_page)
|
33
33
|
|
34
|
-
|
35
|
-
|
34
|
+
# A cache key without a listing instance:
|
35
|
+
Listing.cache_key(:category_in_location_home_page, category_id: 10, location_id: 10)
|
36
36
|
|
37
37
|
|
38
38
|
Your cache keys will be automatically updates after_save and after_destroy according to the attribute changes.
|
@@ -9,7 +9,7 @@ module HasCacheKey
|
|
9
9
|
base.after_destroy :expire_cache_keys
|
10
10
|
end
|
11
11
|
|
12
|
-
def expire_cache_keys
|
12
|
+
def expire_cache_keys(*args)
|
13
13
|
# First, assemble all keys the listing is involved in, and the values that were affected
|
14
14
|
affected_values_by_key = {}
|
15
15
|
attr_changes = self.changes
|
@@ -84,4 +84,4 @@ module HasCacheKey
|
|
84
84
|
end
|
85
85
|
|
86
86
|
require 'active_record'
|
87
|
-
ActiveRecord::Base.class_eval { include HasCacheKey::ModelExt }
|
87
|
+
ActiveRecord::Base.class_eval { include HasCacheKey::ModelExt }
|
@@ -8,10 +8,7 @@ module HasCacheKey
|
|
8
8
|
# PRODUCT{i in 0..COUNT(slot))}
|
9
9
|
# COUNT(VALUES(slot)))
|
10
10
|
def each(&block)
|
11
|
-
if @results
|
12
|
-
@results.each &block
|
13
|
-
return self
|
14
|
-
end
|
11
|
+
return @results.each(&block) if @results
|
15
12
|
@results = []
|
16
13
|
cur_v_i = Array.new(@data.keys.length, 0)
|
17
14
|
keys = @data.keys.sort_by(&:to_s)
|
@@ -1,3 +1,3 @@
|
|
1
1
|
module HasCacheKey
|
2
|
-
VERSION = '0.0.
|
3
|
-
end
|
2
|
+
VERSION = '0.0.2'
|
3
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: has_cache_key
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-03-09 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
16
|
-
requirement: &
|
16
|
+
requirement: &15859040 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: '3.2'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *15859040
|
25
25
|
description: Allows you to define multiple cache keys on the module, and automatically
|
26
26
|
expires them.
|
27
27
|
email: glex.spb@gmail.com
|
@@ -29,16 +29,16 @@ executables: []
|
|
29
29
|
extensions: []
|
30
30
|
extra_rdoc_files: []
|
31
31
|
files:
|
32
|
-
- lib/has_cache_key/
|
32
|
+
- lib/has_cache_key/version.rb
|
33
33
|
- lib/has_cache_key/model_ext.rb
|
34
34
|
- lib/has_cache_key/cache_key.rb
|
35
|
-
- lib/has_cache_key/
|
35
|
+
- lib/has_cache_key/possible_values.rb
|
36
36
|
- lib/has_cache_key.rb
|
37
37
|
- MIT-LICENSE
|
38
38
|
- Rakefile
|
39
39
|
- Gemfile
|
40
40
|
- README.md
|
41
|
-
homepage:
|
41
|
+
homepage: https://github.com/glebm/has_cache_key
|
42
42
|
licenses: []
|
43
43
|
post_install_message:
|
44
44
|
rdoc_options: []
|
@@ -58,8 +58,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
58
58
|
version: '0'
|
59
59
|
requirements: []
|
60
60
|
rubyforge_project:
|
61
|
-
rubygems_version: 1.8.
|
61
|
+
rubygems_version: 1.8.17
|
62
62
|
signing_key:
|
63
63
|
specification_version: 3
|
64
|
-
summary: Automatic Cache Key Management for Rails Models. v0.0.
|
64
|
+
summary: Automatic Cache Key Management for Rails Models. v0.0.2
|
65
65
|
test_files: []
|