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.

Returns:

  • (nil)

    Always returns nil



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

def clean; end

#exists?Boolean

Always returns true regardless of the key.

Returns:

  • (Boolean)

    Always returns true



40
41
42
# File 'lib/zache.rb', line 40

def exists?(*)
  true
end

#get { ... } ⇒ Object

Always returns the result of the block, never caches.

Yields:

  • Block that provides the value

Returns:

  • (Object)

    The result of the block



34
35
36
# File 'lib/zache.rb', line 34

def get(*)
  yield
end

#locked?(_key) ⇒ Boolean

Always returns false.

Parameters:

  • _key (Object)

    Ignored

Returns:

  • (Boolean)

    Always returns false



47
48
49
# File 'lib/zache.rb', line 47

def locked?(_key)
  false
end

#putnil

No-op method that ignores the input.

Returns:

  • (nil)

    Always returns nil



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

def put(*); end

#remove(_key) ⇒ nil

No-op method that ignores the key.

Parameters:

  • _key (Object)

    Ignored

Returns:

  • (nil)

    Always returns nil



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

def remove(_key); end

#remove_allnil

No-op method.

Returns:

  • (nil)

    Always returns nil



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

def remove_all; end

#sizeInteger

Returns a fixed size of 1.

Returns:

  • (Integer)

    Always returns 1



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

def size
  1
end