Class: Kayvee::Clients::Redis

Inherits:
Object
  • Object
show all
Includes:
KeyValueStoreClient
Defined in:
lib/kayvee/clients/redis.rb

Overview

An redis backed kv store

Constant Summary

Constants included from KeyValueStoreClient

KeyValueStoreClient::InterfaceNotImplementedError, KeyValueStoreClient::OptionMissingError

Instance Method Summary collapse

Methods included from KeyValueStoreClient

included

Constructor Details

#initialize(options) ⇒ Redis

Returns a new instance of Redis.

Parameters:

  • options (Hash)

    for the client



14
15
16
17
18
19
# File 'lib/kayvee/clients/redis.rb', line 14

def initialize(options)
  @options = options
  validate_options!

  @store = ::Redis.new(url: 'redis://localhost')
end

Instance Method Details

#clearObject

Raises:

  • (NotImplementedError)


40
41
42
# File 'lib/kayvee/clients/redis.rb', line 40

def clear
  raise NotImplementedError
end

#read(path) ⇒ String\nil

Returns the read string or nil if key does not exist.

Parameters:

  • path (String)

    the path to read

Returns:

  • (String\nil)

    the read string or nil if key does not exist



24
25
26
# File 'lib/kayvee/clients/redis.rb', line 24

def read(path)
  @store.get(_path(path))
end

#sizeObject

Raises:

  • (NotImplementedError)


36
37
38
# File 'lib/kayvee/clients/redis.rb', line 36

def size
  raise NotImplementedError
end

#write(path, value) ⇒ Key

Returns the modified key.

Parameters:

  • path (String)

    the path to read

  • value (String)

    the value to set

Returns:

  • (Key)

    the modified key



32
33
34
# File 'lib/kayvee/clients/redis.rb', line 32

def write(path, value)
  @store.set(_path(path), value)
end