Class: Kayvee::Clients::Memory

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

Overview

An in memory kv store

Direct Known Subclasses

Test

Constant Summary

Constants included from KeyValueStoreClient

KeyValueStoreClient::InterfaceNotImplementedError, KeyValueStoreClient::OptionMissingError

Instance Method Summary collapse

Methods included from KeyValueStoreClient

included

Constructor Details

#initialize(options) ⇒ Memory

Returns a new instance of Memory.

Parameters:

  • options (Hash)

    for the client



8
9
10
11
12
# File 'lib/kayvee/clients/memory.rb', line 8

def initialize(options)
  @options = options
  validate_options!
  @store = {}
end

Instance Method Details

#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



17
18
19
# File 'lib/kayvee/clients/memory.rb', line 17

def read(path)
  @store[path]
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



25
26
27
# File 'lib/kayvee/clients/memory.rb', line 25

def write(path, value)
  @store[path] = value
end