Class: Excursion::Datastores::ActiveRecordWithMemcache
- Inherits:
-
Datastore
- Object
- Datastore
- Excursion::Datastores::ActiveRecordWithMemcache
show all
- Defined in:
- lib/excursion/datastores/active_record_with_memcache.rb
Instance Method Summary
collapse
Methods inherited from Datastore
#all_apps, #app, #application_class
Instance Method Details
#all ⇒ Object
31
32
33
34
35
36
37
|
# File 'lib/excursion/datastores/active_record_with_memcache.rb', line 31
def all
hash = @cache.all
return hash unless hash.nil? || hash.empty?
@model.all
rescue Dalli::RingError => e
rescue_from_dalli_ring_error(e) && retry
end
|
#delete(key) ⇒ Object
Also known as:
unset
25
26
27
28
|
# File 'lib/excursion/datastores/active_record_with_memcache.rb', line 25
def delete(key)
@model.delete(key)
@cache.delete(key)
end
|
#read(key) ⇒ Object
Also known as:
get
8
9
10
11
12
13
14
15
16
|
# File 'lib/excursion/datastores/active_record_with_memcache.rb', line 8
def read(key)
value = @cache.read(key)
return value unless value.nil?
value = @model.read(key)
@cache.write(key, value) unless value.nil?
value
end
|
#write(key, value) ⇒ Object
Also known as:
set
19
20
21
22
|
# File 'lib/excursion/datastores/active_record_with_memcache.rb', line 19
def write(key, value)
@model.write(key, value)
@cache.write(key, value)
end
|