laserlemon-cache_flow 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/VERSION +1 -1
  2. data/cache_flow.gemspec +1 -1
  3. data/lib/cache_flow.rb +18 -2
  4. metadata +3 -2
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.3
1
+ 0.1.4
data/cache_flow.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{cache_flow}
8
- s.version = "0.1.3"
8
+ s.version = "0.1.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["laserlemon"]
data/lib/cache_flow.rb CHANGED
@@ -89,8 +89,24 @@ module LaserLemon
89
89
  end
90
90
 
91
91
  def serialization_cache_key(extension, options)
92
- query = options.except(:cache).reject{|k,v| v.nil? }.to_query
93
- ["#{cache_key}.#{extension}", query].delete_if(&:blank?).join('?')
92
+ query = options.except(:cache, :skip_instruct).reject{|k,v| v.nil? }.to_query
93
+ key = ["#{cache_key}.#{extension}", query].delete_if(&:blank?).join('?')
94
+ if cache_key_limit && (key.size > cache_key_limit)
95
+ "#{cache_key}.#{extension}?#{hashed_serialization_query(query)}"
96
+ else
97
+ key
98
+ end
99
+ end
100
+
101
+ def cache_key_limit
102
+ case Rails.cache.class.name.demodulize.underscore.to_sym
103
+ when :mem_cache_store then 250
104
+ end
105
+ end
106
+
107
+ def hashed_serialization_query(query)
108
+ require 'digest/sha1' unless defined?(Digest) && defined?(Digest::SHA1)
109
+ "cache_flow=#{Digest::SHA1.hexdigest(query)}"
94
110
  end
95
111
  end
96
112
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: laserlemon-cache_flow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - laserlemon
@@ -44,6 +44,7 @@ files:
44
44
  - test/test_helper.rb
45
45
  has_rdoc: false
46
46
  homepage: http://github.com/laserlemon/cache_flow
47
+ licenses:
47
48
  post_install_message:
48
49
  rdoc_options:
49
50
  - --charset=UTF-8
@@ -64,7 +65,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
64
65
  requirements: []
65
66
 
66
67
  rubyforge_project:
67
- rubygems_version: 1.2.0
68
+ rubygems_version: 1.3.5
68
69
  signing_key:
69
70
  specification_version: 3
70
71
  summary: Easily cache ActiveRecord's to_xml and to_json outputs