Class: Kayvee::Store
- Inherits:
-
Object
- Object
- Kayvee::Store
- Defined in:
- lib/kayvee/store.rb
Overview
Represents a simple key value store. Provides multiple backing stores.
Constant Summary collapse
- ClientNotFound =
Raised when a client implementation can not be found.
Class.new(Exception)
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
The internal client driving the store.
Instance Method Summary collapse
-
#clear ⇒ Object
Clear the underlying store.
-
#get(path) ⇒ Key
(also: #[])
Gets a given keys value.
-
#initialize(client = :s3, options = {}) ⇒ Store
constructor
A new instance of Store.
-
#set(path, value) ⇒ Key
(also: #[]=)
Sets a given key to a given value.
- #size ⇒ Object
Constructor Details
#initialize(client = :s3, options = {}) ⇒ Store
Returns a new instance of Store.
33 34 35 36 |
# File 'lib/kayvee/store.rb', line 33 def initialize(client = :s3, = {}) load_client(client) @client = instantiate_client(client, ) end |
Instance Attribute Details
#client ⇒ Object (readonly)
The internal client driving the store
24 25 26 |
# File 'lib/kayvee/store.rb', line 24 def client @client end |
Instance Method Details
#clear ⇒ Object
Clear the underlying store
62 63 64 |
# File 'lib/kayvee/store.rb', line 62 def clear @client.clear end |
#get(path) ⇒ Key Also known as: []
Gets a given keys value
56 57 58 |
# File 'lib/kayvee/store.rb', line 56 def get(path) Kayvee::Key.new(@client, path) end |
#set(path, value) ⇒ Key Also known as: []=
Sets a given key to a given value
44 45 46 47 48 |
# File 'lib/kayvee/store.rb', line 44 def set(path, value) key = Kayvee::Key.new(@client, path) key.write(value) key end |
#size ⇒ Object
66 67 68 |
# File 'lib/kayvee/store.rb', line 66 def size @client.size end |