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



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

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?(_key) ⇒ Boolean

Always returns false.

Parameters:

  • key (Object)

    Ignored

Returns:

  • (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.

Parameters:

  • key (Object)

    Ignored

  • value (Object)

    Ignored

  • opts (Hash)

    Ignored

Returns:

  • (nil)

    Always returns nil



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

def put(*); end

#remove(_key) ⇒ nil

No-op method that ignores the key.

Parameters:

  • _key (Object)

    Ignored

Returns:

  • (nil)

    Always returns nil



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

def remove(_key); end

#remove_allnil

No-op method.

Returns:

  • (nil)

    Always returns nil



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

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