ashleym1972-cache-money 0.2.7 → 0.2.8
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/cash/config.rb +1 -1
- data/lib/cash/index.rb +6 -2
- data/lib/cash/local.rb +1 -1
- data/lib/cash/query/abstract.rb +3 -2
- metadata +1 -1
data/lib/cash/config.rb
CHANGED
@@ -27,7 +27,7 @@ module Cash
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def index(attributes, options = {})
|
30
|
-
options.assert_valid_keys(:ttl, :order, :limit, :buffer)
|
30
|
+
options.assert_valid_keys(:ttl, :order, :limit, :buffer, :order_column)
|
31
31
|
(@cache_config.indices.unshift(Index.new(@cache_config, self, attributes, options))).uniq!
|
32
32
|
end
|
33
33
|
|
data/lib/cash/index.rb
CHANGED
@@ -2,7 +2,7 @@ module Cash
|
|
2
2
|
class Index
|
3
3
|
attr_reader :attributes, :options
|
4
4
|
delegate :each, :hash, :to => :@attributes
|
5
|
-
delegate :get, :set, :expire, :find_every_without_cache, :calculate_without_cache, :calculate_with_cache, :incr, :decr, :primary_key, :to => :@active_record
|
5
|
+
delegate :get, :set, :expire, :find_every_without_cache, :calculate_without_cache, :calculate_with_cache, :incr, :decr, :primary_key, :logger, :to => :@active_record
|
6
6
|
|
7
7
|
DEFAULT_OPTIONS = { :ttl => 1.day }
|
8
8
|
|
@@ -64,6 +64,10 @@ module Cash
|
|
64
64
|
def window
|
65
65
|
limit && limit + buffer
|
66
66
|
end
|
67
|
+
|
68
|
+
def order_column
|
69
|
+
options[:order_column] || 'id'
|
70
|
+
end
|
67
71
|
end
|
68
72
|
include Attributes
|
69
73
|
|
@@ -73,7 +77,7 @@ module Cash
|
|
73
77
|
|
74
78
|
def matches?(query)
|
75
79
|
query.calculation? ||
|
76
|
-
(query.order == [
|
80
|
+
(query.order == [order_column, order] &&
|
77
81
|
(!limit || (query.limit && query.limit + query.offset <= limit)))
|
78
82
|
end
|
79
83
|
|
data/lib/cash/local.rb
CHANGED
data/lib/cash/query/abstract.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Cash
|
2
2
|
module Query
|
3
3
|
class Abstract
|
4
|
-
delegate :with_exclusive_scope, :get, :table_name, :indices, :find_from_ids_without_cache, :cache_key, :columns_hash, :to => :@active_record
|
4
|
+
delegate :with_exclusive_scope, :get, :table_name, :indices, :find_from_ids_without_cache, :cache_key, :columns_hash, :logger, :to => :@active_record
|
5
5
|
|
6
6
|
def self.perform(*args)
|
7
7
|
new(*args).perform
|
@@ -24,6 +24,7 @@ module Cash
|
|
24
24
|
misses, missed_keys, objects = hit_or_miss(cache_keys, index, get_options)
|
25
25
|
format_results(cache_keys, choose_deserialized_objects_if_possible(missed_keys, cache_keys, misses, objects))
|
26
26
|
else
|
27
|
+
logger.debug("---- UNCACHEABLE #{table_name} - #{find_options.inspect} - #{get_options.inspect} - #{@options1.inspect} - #{@options2.inspect}")
|
27
28
|
uncacheable
|
28
29
|
end
|
29
30
|
end
|
@@ -94,7 +95,7 @@ module Cash
|
|
94
95
|
when Hash
|
95
96
|
conditions.to_a.collect { |key, value| [key.to_s, value] }
|
96
97
|
when String
|
97
|
-
parse_indices_from_condition(conditions)
|
98
|
+
parse_indices_from_condition(conditions.gsub('1 = 1 AND ', '')) #ignore unnecessary conditions
|
98
99
|
when Array
|
99
100
|
parse_indices_from_condition(*conditions)
|
100
101
|
when NilClass
|