activerecord_cache_store 0.0.1 → 0.0.2
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/README +12 -0
- data/activerecord_cache_store.gemspec +1 -1
- data/lib/active_support/cache/active_record_store.rb +6 -7
- metadata +3 -3
data/README
CHANGED
@@ -15,7 +15,19 @@ Cache Migration
|
|
15
15
|
===============
|
16
16
|
|
17
17
|
rails g cache_migration
|
18
|
+
rake db:migrate
|
18
19
|
|
20
|
+
Usage
|
21
|
+
=====
|
22
|
+
|
23
|
+
<% cache do %>
|
24
|
+
some html
|
25
|
+
<% end>
|
26
|
+
|
27
|
+
Rails.cache.clear # clear all cache
|
28
|
+
Rails.cache.cleanup # clear expired cache entries
|
29
|
+
|
30
|
+
more about Rails caching http://guides.rubyonrails.org/caching_with_rails.html
|
19
31
|
|
20
32
|
Notes
|
21
33
|
=====
|
@@ -5,26 +5,26 @@ module ActiveSupport
|
|
5
5
|
class ActiveRecordStore < Store
|
6
6
|
|
7
7
|
def cleanup(options = nil)
|
8
|
-
|
8
|
+
CacheEntry.expired.delete_all
|
9
9
|
end
|
10
10
|
|
11
11
|
def clear(options = nil)
|
12
|
-
|
12
|
+
CacheEntry.delete_all
|
13
13
|
end
|
14
14
|
|
15
15
|
private
|
16
16
|
|
17
17
|
def read_entry(key, options)
|
18
|
-
if entry =
|
18
|
+
if entry = CacheEntry.find_by_key(key)
|
19
19
|
entry.to_cache_entry
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
23
|
def write_entry(key, entry, options)
|
24
|
-
if cache =
|
24
|
+
if cache = CacheEntry.find_by_key(key)
|
25
25
|
delete_entry(key, {})
|
26
26
|
end
|
27
|
-
|
27
|
+
CacheEntry.create!({
|
28
28
|
:key => key,
|
29
29
|
:value => entry.value,
|
30
30
|
:created_at => entry.created_at,
|
@@ -33,8 +33,7 @@ module ActiveSupport
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def delete_entry(key, options)
|
36
|
-
|
37
|
-
::CacheEntry.where(:key => key).delete_all
|
36
|
+
CacheEntry.where(:key => key).delete_all
|
38
37
|
end
|
39
38
|
end
|
40
39
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord_cache_store
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Tomasz Mazur
|