Class: Elephas::Backends::Base

Inherits:
Object
  • Object
show all
Includes:
Lazier::I18n
Defined in:
lib/elephas/backends/base.rb

Overview

The a base backend. All data-related methods must be overriden.

Direct Known Subclasses

Hash, RubyOnRails

Instance Method Summary (collapse)

Instance Method Details

- (TrueClass|FalseClass) delete(key)

Deletes a value from the cache.

Parameters:

  • key (String)

    The key to delete.

Returns:

  • (TrueClass|FalseClass)

    true if the key was in the cache, false otherwise.



37
38
39
# File 'lib/elephas/backends/base.rb', line 37

def delete(key)
  unimplemented
end

- (TrueClass|FalseClass) exists?(key)

Checks if a key exists in the cache.

Parameters:

  • key (String)

    The key to lookup.

Returns:

  • (TrueClass|FalseClass)

    true if the key is in the cache, false otherwise.



45
46
47
# File 'lib/elephas/backends/base.rb', line 45

def exists?(key)
  unimplemented
end

- (Object) now

Returns the current time for comparing with entries TTL.

Returns:

  • (Object)

    A representation of the current time.



52
53
54
# File 'lib/elephas/backends/base.rb', line 52

def now
  ::Time.now.to_f
end

- (Entry|NilClass) read(key)

Reads a value from the cache.

Parameters:

  • key (String)

    The key to lookup.

Returns:

  • (Entry|NilClass)

    The read value or nil.



18
19
20
# File 'lib/elephas/backends/base.rb', line 18

def read(key)
  unimplemented
end

- (Object) write(key, value, options = {})

Writes a value to the cache.

Parameters:

  • key (String)

    The key to associate the value with.

  • value (Object)

    The value to write. Setting a value to nil doesn’t mean deleting the value.

  • options (Hash) (defaults to: {})

    A list of options for writing.

Returns:

  • (Object)

    The value itself.

See Also:

  • Cache.setup_options


29
30
31
# File 'lib/elephas/backends/base.rb', line 29

def write(key, value, options = {})
  unimplemented
end