new Sqlite3ProducerDb(databaseFilePath)
Sqlite3ProducerDb extends ProducerDb to implement storage of keys for the
producer using SQLite3. It contains one table that maps time slots (to the
nearest hour) to the content key created for that time slot.
Create a Sqlite3ProducerDb to use the given SQLite3 file.
Parameters:
Name | Type | Description |
---|---|---|
databaseFilePath |
string | The path of the SQLite file. |
- Source:
Throws:
ProducerDb.Error for a database error.
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
getPromise_()
Call Sqlite3Promise.getPromise, wrapping an Error in ProducerDb.Error.
- Source:
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
runPromise_()
Call Sqlite3Promise.runPromise, wrapping an Error in ProducerDb.Error.
- Source: