Class finesse.utilities.DesktopCache
RestCacheDataService allows gadgets to cache there data locally
in IndexedDB that can be available across the failover on the other side without even making
a REST call.
Defined in: finesse.js.
Constructor Attributes | Constructor Name and Description |
---|---|
Method Attributes | Method Name and Description |
---|---|
clearData(callback)
Clear all the records in the DB.
|
|
deleteData(key, callback)
Delete a record from DB.
|
|
fetchData(key, callback)
Fetch a single or all records from DB.
|
|
saveOrUpdateData(records, callback)
Save or update a single or multiple records in the DB.
|
|
setGroup(groupName)
Different gadgets from the same vendor can choose to keep the same group to reduce the redundancy in the data stored.
|
Method Detail
clearData(callback)
Clear all the records in the DB.
- Parameters:
- callback
- is a callback function to be passed as all the indexeddb operations are asynchronous in nature.
deleteData(key, callback)
Delete a record from DB.
- Parameters:
- key
- is the Rest name which is used to identify the record to be deleted.
- callback
- is a callback function to be passed as all the indexeddb operations are asynchronous in nature.
fetchData(key, callback)
Fetch a single or all records from DB.
finesse.utilities.DesktopCache.fetchData('someKey', function (err, data){ if (!err) // do something });
- Parameters:
- key
- is through which one can retrieve a single record. Key should be unique, it is like a primary key.
- callback
- is the callback to be called in case of successful/error fetching of the data
saveOrUpdateData(records, callback)
Save or update a single or multiple records in the DB.
finesse.utilities.DesktopCache.saveOrUpdateData({[ key: 'someKey' data: 'someData' ]}, function (err, data){ if (!err) // do something });
- Parameters:
- {Array} records
- is an array containing the data to be saved in the DB. It will always be an array even if there is just one record that has to be saved/updated.
- callback
- is a callback function to be passed as all the indexeddb operations are asynchronous in nature.
setGroup(groupName)
Different gadgets from the same vendor can choose to keep the same group to reduce the redundancy in the data stored.
The group name set here will be used as a prefix to the key while saving that record.
- Parameters:
- groupName
- is the name which would prefix the keys while saving in the cache.