Class: ObjectCache::CacheStore

Inherits:
Object
  • Object
show all
Defined in:
lib/object_cache/cache_store.rb

Direct Known Subclasses

MemoryStore, RailsStore

Class Method Summary collapse

Class Method Details

.array_or_value(results, ids) ⇒ Object



42
43
44
45
46
47
48
# File 'lib/object_cache/cache_store.rb', line 42

def array_or_value(results, ids)
  if ids.class == Array
    results
  else
    results.first
  end
end

.fetch(klass, ids) ⇒ Object

Raises:

  • (NotImplementedError)


5
6
7
# File 'lib/object_cache/cache_store.rb', line 5

def fetch(klass, ids)
  raise NotImplementedError
end

.fetch_fresh_results(klass, to_set) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/object_cache/cache_store.rb', line 29

def fetch_fresh_results(klass, to_set)
  #puts to_set.inspect
  return nil if to_set.size == 0
  results = []
  fresh_results = fetch_from_array(klass, to_set)

  fresh_results.each do |item|
    results << set(klass, item.id, item)
  end

  results
end

.fetch_from_array(klass, ids) ⇒ Object



25
26
27
# File 'lib/object_cache/cache_store.rb', line 25

def fetch_from_array(klass, ids)
  ObjectCache.constantize(klass).find(ids)
end

.get(klass, id) ⇒ Object

Raises:

  • (NotImplementedError)


9
10
11
# File 'lib/object_cache/cache_store.rb', line 9

def get(klass, id)
  raise NotImplementedError
end

.hash_get(key) ⇒ Object

Raises:

  • (NotImplementedError)


17
18
19
# File 'lib/object_cache/cache_store.rb', line 17

def hash_get(key)
  raise NotImplementedError
end

.hash_set(key, value) ⇒ Object

Raises:

  • (NotImplementedError)


21
22
23
# File 'lib/object_cache/cache_store.rb', line 21

def hash_set(key, value)
  raise NotImplementedError
end

.set(klass, id, value) ⇒ Object

Raises:

  • (NotImplementedError)


13
14
15
# File 'lib/object_cache/cache_store.rb', line 13

def set(klass, id, value)
  raise NotImplementedError
end