new IndexedDbProducerDb(databaseName)
IndexedDbProducerDb extends ProducerDb to implement storage of keys for the
producer using the browser's IndexedDB service. It contains one table that
maps time slots (to the nearest hour) to the content key created for that
time slot.
Create an IndexedDbProducerDb to use the given IndexedDB database name.
Parameters:
Name | Type | Description |
---|---|---|
databaseName |
string | IndexedDB database name. |
- Source:
Methods
addContentKeyPromise(timeSlot, key, useSync) → {Promise}
Add key as the content key for the hour covering timeSlot.
Parameters:
Name | Type | Description |
---|---|---|
timeSlot |
number | The time slot as milliseconds since Jan 1, 1970 UTC. |
key |
Blob | The encoded key. |
useSync |
boolean | (optional) If true then return a rejected promise since this only supports async code. |
- Source:
Returns:
A promise that fulfills when the key is added, or that
is rejected with ProducerDb.Error if a key for the same hour already exists
in the database, or other database error.
- Type
- Promise
deleteContentKeyPromise(timeSlot, useSync) → {Promise}
Delete the content key for the hour covering timeSlot. If there is no key for
the time slot, do nothing.
Parameters:
Name | Type | Description |
---|---|---|
timeSlot |
number | The time slot as milliseconds since Jan 1, 1970 UTC. |
useSync |
boolean | (optional) If true then return a rejected promise since this only supports async code. |
- Source:
Returns:
A promise that fulfills when the key is deleted (or there
is no such key), or that is rejected with ProducerDb.Error for a database
error.
- Type
- Promise
getContentKeyPromise(timeSlot, useSync) → {Promise}
Get the content key for the hour covering timeSlot.
Parameters:
Name | Type | Description |
---|---|---|
timeSlot |
number | The time slot as milliseconds since Jan 1, 1970 UTC. |
useSync |
boolean | (optional) If true then return a rejected promise since this only supports async code. |
- Source:
Returns:
A promise that returns a Blob with the encoded key, or that
is rejected with ProducerDb.Error if there is no key covering timeSlot, or
other database error
- Type
- Promise
hasContentKeyPromise(timeSlot, useSync) → {Promise}
Check if a content key exists for the hour covering timeSlot.
Parameters:
Name | Type | Description |
---|---|---|
timeSlot |
number | The time slot as milliseconds since Jan 1, 1970 UTC. |
useSync |
boolean | (optional) If true then return a rejected promise since this only supports async code. |
- Source:
Returns:
A promise that returns true if there is a content key for
timeSlot (else false), or that is rejected with ProducerDb.Error for a
database error.
- Type
- Promise