Class: StorageClient

Storage Client

The Storage client handles saving and retrieving data for your application.

new StorageClient
()
clients/storageClient.js, line 21

TODO
  • add clear method

Methods

get
(params, cb)
clients/storageClient.js, line 110

Get a value from storage.

Name Type Description
params Object

Params object

Name Type Description
key String

The key to get from storage

cb function optional

callback to be called on success

Example
StorageClient.get({topic:"finsemble", key:"testKey"}, function(err, data){
	var myData = data;
});

keys
(params, cb)
clients/storageClient.js, line 137

Get all keys for the topic.

Name Type Description
params Object

Params object

Name Type Description
topic String

topic for the keys to return

keyPrefix String optional

filter all keys that don't start with this prefix

cb function optional

callback to be called on success

Example
StorageClient.keys({topic:"finsemble", keyPrefix:"test"}, function(err, data){
	var myKeys = data;
});

remove
(params)
clients/storageClient.js, line 180

Delete a value from storage.

Name Type Description
params Object

Params object

Name Type Description
key String

The key to get from storage

Example
StorageClient.remove({key:"testKey"})

save
(params, cb)
clients/storageClient.js, line 85

Save a key value pair into storage.

Name Type Description
params Object

Params object

Name Type Description
topic String

storage topic for key being stored

key String

The key to be stored

value any

The value to be stored

cb function optional

callback to be called on success

Example
StorageClient.save({topic:"finsemble", key:"testKey", value:"testValue"})

setStore
(params, cb)
clients/storageClient.js, line 59

Specifies the datastore. For normal operation this function doesn't have to be invoked -- the default datastore is set in configuration.

Name Type Description
params Object

Params object

Name Type Description
topic String

if specificed then data store is set only for topic

dataStore string

identifies the data store (e.g. "localStorage", "redis")

cb function optional

callback to be called on success

Example
StorageClient.setStore({topic:"finsemble", dataStore:"redis"})

setUser
(params, cb)
clients/storageClient.js, line 35

Define the username for storage (i.e., each user has unique storage)

Name Type Description
params Object

Params object

Name Type Description
user String

user name

cb function optional

callback to be called on success

Example
StorageClient.setUser({ user: "JohnDoe"});