redvex-ar_cache 0.1.3 → 0.1.4
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/Rakefile +1 -1
- data/ar_cache.gemspec +2 -2
- data/lib/ar_cache.rb +28 -1
- metadata +4 -3
data/Rakefile
CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
|
|
2
2
|
require 'rake'
|
3
3
|
require 'echoe'
|
4
4
|
|
5
|
-
Echoe.new('ar_cache', '0.1.
|
5
|
+
Echoe.new('ar_cache', '0.1.4') do |p|
|
6
6
|
p.description = "Performe ActiveRecord cache in File System for heavy and repetitive query."
|
7
7
|
p.url = "http://github.com/redvex/ar_cache"
|
8
8
|
p.author = "Gianni Mazza"
|
data/ar_cache.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{ar_cache}
|
5
|
-
s.version = "0.1.
|
5
|
+
s.version = "0.1.4"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Gianni Mazza"]
|
9
|
-
s.date = %q{2009-09-
|
9
|
+
s.date = %q{2009-09-17}
|
10
10
|
s.description = %q{Performe ActiveRecord cache in File System for heavy and repetitive query.}
|
11
11
|
s.email = %q{redvex@me.com}
|
12
12
|
s.extra_rdoc_files = ["CHANGELOG", "lib/ar_cache.rb", "README.rdoc"]
|
data/lib/ar_cache.rb
CHANGED
@@ -58,6 +58,30 @@ module ArCache
|
|
58
58
|
return out
|
59
59
|
end
|
60
60
|
|
61
|
+
def find(id, params=nil)
|
62
|
+
if params[:cache]
|
63
|
+
params.delete(:cache)
|
64
|
+
cache_find(id, params)
|
65
|
+
elsif params[:cache_reset]
|
66
|
+
params.delete(:cache_reset)
|
67
|
+
super(id,params)
|
68
|
+
else
|
69
|
+
super(id,params)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def find_first(params=nil)
|
74
|
+
find(:first, params)
|
75
|
+
end
|
76
|
+
|
77
|
+
def find_last(params=nil)
|
78
|
+
find(:last, params)
|
79
|
+
end
|
80
|
+
|
81
|
+
def find_all(params=nil)
|
82
|
+
find(:all, params)
|
83
|
+
end
|
84
|
+
|
61
85
|
def cache_find_first(params=nil)
|
62
86
|
return cache_find(:first, params)
|
63
87
|
end
|
@@ -102,7 +126,7 @@ module ArCache
|
|
102
126
|
def cache_reset?(file)
|
103
127
|
filename = File.join(RAILS_ROOT, "config", "database.yml")
|
104
128
|
dbconf = YAML.load_file(filename)[RAILS_ENV]
|
105
|
-
if dbconf["cache_expire"].nil?
|
129
|
+
if dbconf["cache_expire"].nil? and File.exists?(file)
|
106
130
|
return false
|
107
131
|
else
|
108
132
|
return File.open(file).ctime + dbconf["cache_expire"] > Time.now
|
@@ -110,6 +134,9 @@ module ArCache
|
|
110
134
|
end
|
111
135
|
|
112
136
|
def calculate_file_name(id, params)
|
137
|
+
if params.nil?
|
138
|
+
params = Array.new
|
139
|
+
end
|
113
140
|
File.join(RAILS_ROOT, "tmp", "cache",
|
114
141
|
Digest::MD5.hexdigest(class_name + "--" + id.to_s + "--"+ params.values.join("--"))+".query")
|
115
142
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redvex-ar_cache
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gianni Mazza
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-09-
|
12
|
+
date: 2009-09-17 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -42,6 +42,7 @@ files:
|
|
42
42
|
- ar_cache.gemspec
|
43
43
|
has_rdoc: false
|
44
44
|
homepage: http://github.com/redvex/ar_cache
|
45
|
+
licenses:
|
45
46
|
post_install_message:
|
46
47
|
rdoc_options:
|
47
48
|
- --line-numbers
|
@@ -67,7 +68,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
67
68
|
requirements: []
|
68
69
|
|
69
70
|
rubyforge_project: ar_cache
|
70
|
-
rubygems_version: 1.
|
71
|
+
rubygems_version: 1.3.5
|
71
72
|
signing_key:
|
72
73
|
specification_version: 3
|
73
74
|
summary: Performe ActiveRecord cache in File System for heavy and repetitive query.
|