Class: Geocoder::CacheStore::Generic

Inherits:
Base
  • Object
show all
Defined in:
lib/geocoder/cache_stores/generic.rb

Instance Method Summary collapse

Methods inherited from Base

#initialize, #urls

Constructor Details

This class inherits a constructor from Geocoder::CacheStore::Base

Instance Method Details

#keysObject



27
28
29
# File 'lib/geocoder/cache_stores/generic.rb', line 27

def keys
  store.keys
end

#read(url) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'lib/geocoder/cache_stores/generic.rb', line 16

def read(url)
  case
  when store.respond_to?(:[])
    store[key_for(url)]
  when store.respond_to?(:get)
    store.get key_for(url)
  when store.respond_to?(:read)
    store.read key_for(url)
  end
end

#remove(key) ⇒ Object



31
32
33
# File 'lib/geocoder/cache_stores/generic.rb', line 31

def remove(key)
  store.delete(key)
end

#write(url, value) ⇒ Object



5
6
7
8
9
10
11
12
13
14
# File 'lib/geocoder/cache_stores/generic.rb', line 5

def write(url, value)
  case
  when store.respond_to?(:[]=)
    store[key_for(url)] = value
  when store.respond_to?(:set)
    store.set key_for(url), value
  when store.respond_to?(:write)
    store.write key_for(url), value
  end
end