staugaard-magic_cache_keys 0.4.0 → 0.5.0

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.
Files changed (3) hide show
  1. data/VERSION.yml +1 -1
  2. data/lib/magic_cache_keys.rb +5 -17
  3. metadata +2 -2
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :patch: 0
3
3
  :major: 0
4
- :minor: 4
4
+ :minor: 5
@@ -4,27 +4,15 @@ module ActiveRecord
4
4
  module CacheKeyCaching
5
5
  module AssociationCollectionExtension
6
6
  def cache_key
7
- options = {:conditions => sanitize_sql({@reflection.primary_key_name => @owner.id})}
8
- options[:conditions] << " AND (#{conditions})" if conditions
7
+ key = @reflection.klass.cache_key(scope(:find))
9
8
 
10
- if @reflection.options[:order]
11
- options[:order] = @reflection.options[:order]
12
- end
13
- construct_find_options!(options)
14
- merge_options_from_reflection!(options)
15
-
16
- key = @reflection.klass.cache_key(options)
17
-
18
9
  new_records_count = @target.select { |r| r.new_record? }.size
10
+
11
+ key << "/#{new_records_count}new" if new_records_count > 0
19
12
 
20
- if new_records_count > 0
21
- key + "/#{new_records_count}new"
22
- else
23
- key.dup
24
- end
13
+ key
25
14
  end
26
15
  end
27
-
28
16
  end
29
17
 
30
18
  class Base
@@ -39,7 +27,7 @@ module ActiveRecord
39
27
  class << self
40
28
  def cache_key(options = {})
41
29
  order = options.delete(:order) || scope(:find, :order)
42
- opts = {:select => "MD5(CONCAT(GROUP_CONCAT(CONV(#{table_name}.id,10,36)#{ ' ORDER BY ' + order unless order.blank?}), MAX(#{table_name}.updated_at))) as cached_key"}.reverse_merge(options)
30
+ opts = {:select => "MD5(CONCAT(GROUP_CONCAT(CONV(#{quoted_table_name}.#{connection.quote_column_name(primary_key)},10,36)#{ ' ORDER BY ' + order unless order.blank?}), MAX(#{table_name}.updated_at))) as cached_key"}.reverse_merge(options)
43
31
 
44
32
  connection.execute('SET group_concat_max_len = 1048576')
45
33
  "#{model_name.cache_key}/#{connection.select_value(construct_finder_sql(opts)) || 'empty'}"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: staugaard-magic_cache_keys
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mick Staugaard
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2009-04-17 00:00:00 -07:00
13
+ date: 2009-04-19 00:00:00 -07:00
14
14
  default_executable:
15
15
  dependencies: []
16
16