Class: ProducerDb

ProducerDb

new ProducerDb()

ProducerDb is a base class the storage of keys for the producer. It contains one table that maps time slots (to the nearest hour) to the content key created for that time slot. A subclass must implement the methods. For example, see Sqlite3ProducerDb (for Nodejs) or IndexedDbProducerDb (for the browser).
Source:

Classes

Error

Methods

(static) getFixedTimeSlot(timeSlot) → {number}

Get the hour-based time slot.
Parameters:
Name Type Description
timeSlot number The time slot as milliseconds since Jan 1, 1970 UTC.
Source:
Returns:
The hour-based time slot as hours since Jan 1, 1970 UTC.
Type
number

addContentKeyPromise(timeSlot, key, useSync) → {Promise|SyncPromise}

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 SyncPromise which is already fulfilled. If omitted or false, this may return a SyncPromise or an async Promise.
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 | SyncPromise

deleteContentKeyPromise(timeSlot, useSync) → {Promise|SyncPromise}

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 SyncPromise which is already fulfilled. If omitted or false, this may return a SyncPromise or an async Promise.
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 | SyncPromise

getContentKeyPromise(timeSlot, useSync) → {Promise|SyncPromise}

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 SyncPromise which is already fulfilled. If omitted or false, this may return a SyncPromise or an async Promise.
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 | SyncPromise

hasContentKeyPromise(timeSlot, useSync) → {Promise|SyncPromise}

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 SyncPromise which is already fulfilled. If omitted or false, this may return a SyncPromise or an async Promise.
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 | SyncPromise