seifertd-cache-money 0.2.5.2 → 0.2.6
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.
- data/lib/cash/accessor.rb +13 -1
- data/lib/cash/index.rb +1 -1
- data/lib/cash/query/abstract.rb +18 -2
- metadata +9 -7
data/lib/cash/accessor.rb
CHANGED
@@ -9,13 +9,24 @@ module Cash
|
|
9
9
|
|
10
10
|
module ClassMethods
|
11
11
|
def fetch(keys, options = {}, &block)
|
12
|
+
#puts "IN FETCH, KEYS: #{keys.inspect}, OPTIONS: #{options.inspect}, BLOCK: #{block.inspect}"
|
12
13
|
case keys
|
13
14
|
when Array
|
14
15
|
keys = keys.collect { |key| cache_key(key) }
|
16
|
+
#puts "KEYS ARE ARRAY #{keys.inspect}"
|
15
17
|
hits = repository.get_multi(keys)
|
18
|
+
#puts "HITS: #{hits.keys.inspect}"
|
16
19
|
if (missed_keys = keys - hits.keys).any?
|
20
|
+
#puts "MISSED KEYS: #{missed_keys.inspect}"
|
17
21
|
missed_values = block.call(missed_keys)
|
18
|
-
|
22
|
+
#puts "MISSED VALUES: #{missed_values.inspect}"
|
23
|
+
# Stuff the newly hit stuff into the cache? Dubious?
|
24
|
+
key_to_value = missed_keys.zip(Array(missed_values)).to_hash
|
25
|
+
key_to_value.each do |new_key, new_val|
|
26
|
+
#puts "CALLING SET #{new_key.inspect} => #{new_val.inspect}"
|
27
|
+
repository.set(new_key, new_val, options[:ttl] || 0, options[:raw])
|
28
|
+
end
|
29
|
+
hits.merge!(key_to_value)
|
19
30
|
end
|
20
31
|
hits
|
21
32
|
else
|
@@ -24,6 +35,7 @@ module Cash
|
|
24
35
|
end
|
25
36
|
|
26
37
|
def get(keys, options = {}, &block)
|
38
|
+
#puts "IN GET, KEYS: #{keys.inspect}, OPTIONS: #{options.inspect}"
|
27
39
|
case keys
|
28
40
|
when Array
|
29
41
|
fetch(keys, options, &block)
|
data/lib/cash/index.rb
CHANGED
data/lib/cash/query/abstract.rb
CHANGED
@@ -12,10 +12,12 @@ module Cash
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def perform(find_options = {}, get_options = {})
|
15
|
+
#puts "CALLING PEFORM: options1: #{@options1.inspect}, options2: #{@options2.inspect}, find_options: #{find_options.inspect}, get_options: #{get_options.inspect}"
|
15
16
|
if cache_config = cacheable?(@options1, @options2, find_options)
|
16
17
|
cache_keys, index = cache_keys(cache_config[0]), cache_config[1]
|
17
|
-
|
18
|
+
#puts "CACHE KEYS: #{cache_keys.inspect}"
|
18
19
|
misses, missed_keys, objects = hit_or_miss(cache_keys, index, get_options)
|
20
|
+
#puts "MISSES: #{misses.inspect}, MISSED_KEYS: #{missed_keys.inspect}"
|
19
21
|
format_results(cache_keys, choose_deserialized_objects_if_possible(missed_keys, cache_keys, misses, objects))
|
20
22
|
else
|
21
23
|
uncacheable
|
@@ -49,12 +51,21 @@ module Cash
|
|
49
51
|
|
50
52
|
private
|
51
53
|
def cacheable?(*optionss)
|
54
|
+
#puts "CALLING CACHEABLE?: optionss: #{optionss.inspect}"
|
52
55
|
optionss.each { |options| return unless safe_options_for_cache?(options) }
|
56
|
+
#puts "ALL OPTIONS ARE SAFE FOR CACHE"
|
53
57
|
partial_indices = optionss.collect { |options| attribute_value_pairs_for_conditions(options[:conditions]) }
|
58
|
+
#puts "PARTIAL INDICES: #{partial_indices.inspect}"
|
54
59
|
return if partial_indices.include?(nil)
|
60
|
+
#puts "NONE OF THE PARTIAL INDICES INCLUDED NIL"
|
61
|
+
#puts "SUM??? #{partial_indices.sum.inspect}"
|
55
62
|
attribute_value_pairs = partial_indices.sum.sort { |x, y| x[0] <=> y[0] }
|
63
|
+
#puts "ATTRIBUTE_VALUE_PAIRS: #{attribute_value_pairs.inspect}"
|
56
64
|
if index = indexed_on?(attribute_value_pairs.collect { |pair| pair[0] })
|
65
|
+
#puts "GOT A MATCHING INDEX: #{index.attributes.inspect}, CHECKING IF QUERY MATCHES"
|
66
|
+
#puts "QUERY ORDER: #{order.inspect}, INDEX ORDER: #{index.order.inspect}"
|
57
67
|
if index.matches?(self)
|
68
|
+
#puts "QUERY MATCHES INDEX! YES!"
|
58
69
|
[attribute_value_pairs, index]
|
59
70
|
end
|
60
71
|
end
|
@@ -111,11 +122,16 @@ module Cash
|
|
111
122
|
end
|
112
123
|
|
113
124
|
def indexed_on?(attributes)
|
114
|
-
|
125
|
+
#puts "CHECKING IF AN INDEX MATCHES: #{attributes.inspect}"
|
126
|
+
indices.detect do |index|
|
127
|
+
#puts " -> INDEX ATTRIBUTES: #{index.attributes.inspect}"
|
128
|
+
index == attributes
|
129
|
+
end
|
115
130
|
end
|
116
131
|
alias_method :index_for, :indexed_on?
|
117
132
|
|
118
133
|
def format_results(cache_keys, objects)
|
134
|
+
#puts "IN FORMAT RESULTS"
|
119
135
|
return objects if objects.blank?
|
120
136
|
|
121
137
|
objects = convert_to_array(cache_keys, objects)
|
metadata
CHANGED
@@ -1,15 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: seifertd-cache-money
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Kallen
|
8
|
+
- Doug Seifert
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
12
|
|
12
|
-
date:
|
13
|
+
date: 2009-08-25 00:00:00 -07:00
|
13
14
|
default_executable:
|
14
15
|
dependencies:
|
15
16
|
- !ruby/object:Gem::Dependency
|
@@ -18,7 +19,7 @@ dependencies:
|
|
18
19
|
version_requirement:
|
19
20
|
version_requirements: !ruby/object:Gem::Requirement
|
20
21
|
requirements:
|
21
|
-
- - "
|
22
|
+
- - ">="
|
22
23
|
- !ruby/object:Gem::Version
|
23
24
|
version: 2.3.2
|
24
25
|
version:
|
@@ -28,7 +29,7 @@ dependencies:
|
|
28
29
|
version_requirement:
|
29
30
|
version_requirements: !ruby/object:Gem::Requirement
|
30
31
|
requirements:
|
31
|
-
- - "
|
32
|
+
- - ">="
|
32
33
|
- !ruby/object:Gem::Version
|
33
34
|
version: 2.3.2
|
34
35
|
version:
|
@@ -43,7 +44,7 @@ dependencies:
|
|
43
44
|
version: 1.5.0
|
44
45
|
version:
|
45
46
|
description: Cache utilities.
|
46
|
-
email:
|
47
|
+
email: doug@dseifert.net
|
47
48
|
executables: []
|
48
49
|
|
49
50
|
extensions: []
|
@@ -72,7 +73,8 @@ files:
|
|
72
73
|
- lib/cash/write_through.rb
|
73
74
|
- lib/cache_money.rb
|
74
75
|
has_rdoc: false
|
75
|
-
homepage: http://github.com/
|
76
|
+
homepage: http://github.com/seifertd/cache-money
|
77
|
+
licenses:
|
76
78
|
post_install_message:
|
77
79
|
rdoc_options: []
|
78
80
|
|
@@ -93,7 +95,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
93
95
|
requirements: []
|
94
96
|
|
95
97
|
rubyforge_project:
|
96
|
-
rubygems_version: 1.
|
98
|
+
rubygems_version: 1.3.5
|
97
99
|
signing_key:
|
98
100
|
specification_version: 2
|
99
101
|
summary: Write-through and Read-through Cacheing for ActiveRecord
|