# Class: KeyValueStore

## KeyValueStore

#### new KeyValueStore(nameopt, optionsopt)

The key value store class used when storing basic in-memory KV data, and can be queried for quick retrieval. Mostly used for collection primary key indexes and lookups.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`name` | String | <optional> | Optional KV store name.
`options` | Object | <optional> | Optional KV store options object. Currently supports "primaryKey" as a string.

Source:
  - KeyValueStore.js, line 14

### Methods

- get(key) → {*}
- lookup(val) → {*}
- primaryKey(key) → {*}
- set(key, value) → {*}
- truncate() → {*}
- uniqueSet(key, value) → {Boolean}
- unSet(key) → {*}

#### get(key) → {*}

Gets data stored for the passed key.

##### Parameters:

Name | Type | Description
--- | --- | ---
`key` | String | The key to get data for.

Source:
  - KeyValueStore.js, line 77

##### Returns:

Type
  *

#### lookup(val) → {*}

Get / set the primary key.

##### Parameters:

Name | Type | Description
--- | --- | ---
`val` | * | A lookup query.

Source:
  - KeyValueStore.js, line 86

##### Returns:

Type
  *

#### primaryKey(key) → {*}

Get / set the primary key.

##### Parameters:

Name | Type | Description
--- | --- | ---
`key` | String | The key to set.

Source:
  - KeyValueStore.js, line 43

##### Returns:

Type
  *

#### set(key, value) → {*}

Sets data against a key in the store.

##### Parameters:

Name | Type | Description
--- | --- | ---
`key` | String | The key to set data for.
`value` | * | The value to assign to the key.

Source:
  - KeyValueStore.js, line 67

##### Returns:

Type
  *

#### truncate() → {*}

Removes all data from the store.

Source:
  - KeyValueStore.js, line 56

##### Returns:

Type
  *

#### uniqueSet(key, value) → {Boolean}

Sets data for the give key in the store only where the given key does not already have a value in the store.

##### Parameters:

Name | Type | Description
--- | --- | ---
`key` | String | The key to set data for.
`value` | * | The value to assign to the key.

Source:
  - KeyValueStore.js, line 247

##### Returns:

True if data was set or false if data already exists for the key.

Type
  Boolean

#### unSet(key) → {*}

Removes data for the given key from the store.

##### Parameters:

Name | Type | Description
--- | --- | ---
`key` | String | The key to un-set.

Source:
  - KeyValueStore.js, line 234

##### Returns:

Type
  *