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



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

def clean; end

#exists?Boolean

Always returns true regardless of the key.

Parameters:

  • key (Object)

    Ignored

  • opts (Hash)

    Ignored

Returns:

  • (Boolean)

    Always returns true



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

def exists?(*)
  true
end

#get { ... } ⇒ Object

Always returns the result of the block, never caches.

Parameters:

  • key (Object)

    Ignored

  • opts (Hash)

    Ignored

Yields:

  • Block that provides the value

Returns:

  • (Object)

    The result of the block



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

def get(*)
  yield
end

#locked?Boolean

Always returns false.

Returns:

  • (Boolean)

    Always returns false



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

def locked?
  false
end

#putnil

No-op method that ignores the input.

Parameters:

  • key (Object)

    Ignored

  • value (Object)

    Ignored

  • opts (Hash)

    Ignored

Returns:

  • (nil)

    Always returns nil



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

def put(*); end

#remove(_key) ⇒ nil

No-op method that ignores the key.

Parameters:

  • _key (Object)

    Ignored

Returns:

  • (nil)

    Always returns nil



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

def remove(_key); end

#remove_allnil

No-op method.

Returns:

  • (nil)

    Always returns nil



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

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