Class: Zache::Fake

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

Overview

Fake implementation that doesn’t cache anything, but behaves like it does. It implements all methods of the original class, but doesn’t do any caching. This is very useful for testing.

Instance Method Summary collapse

Instance Method Details

#cleannil

No-op method.



73
# File 'lib/zache.rb', line 73

def clean; end

#exists?Boolean

Always returns true regardless of the key.



44
45
46
# File 'lib/zache.rb', line 44

def exists?(*)
  true
end

#get { ... } ⇒ Object

Always returns the result of the block, never caches.

Yields:

  • Block that provides the value



36
37
38
# File 'lib/zache.rb', line 36

def get(*)
  yield
end

#locked?(_key) ⇒ Boolean

Always returns false.



51
52
53
# File 'lib/zache.rb', line 51

def locked?(_key)
  false
end

#putnil

No-op method that ignores the input.



60
# File 'lib/zache.rb', line 60

def put(*); end

#remove(_key) ⇒ nil

No-op method that ignores the key.



65
# File 'lib/zache.rb', line 65

def remove(_key); end

#remove_allnil

No-op method.



69
# File 'lib/zache.rb', line 69

def remove_all; end

#sizeInteger

Returns a fixed size of 1.



27
28
29
# File 'lib/zache.rb', line 27

def size
  1
end