Module: Elephas::Providers::Base

Extended by:
ActiveSupport::Concern
Includes:
Lazier::I18n
Included in:
Hash, RubyOnRails
Defined in:
lib/elephas/provider.rb

Overview

The base provider, with all methods a valid provider should override.

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.



39
40
41
# File 'lib/elephas/provider.rb', line 39

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.



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

def exists?(key)
  unimplemented
end

- (Object) now

Returns the current time for comparing with entries TTL.

Returns:

  • (Object)

    A representation of the current time.



54
55
56
# File 'lib/elephas/provider.rb', line 54

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.



20
21
22
# File 'lib/elephas/provider.rb', line 20

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:



31
32
33
# File 'lib/elephas/provider.rb', line 31

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