+ const { viewerKey } = this.generateLocalVideoViewerKeys(options.ip, options.videoId)
+
+ return this.getObject(viewerKey)
+ }
+
+ setLocalVideoViewer (ip: string, videoId: number, object: any) {
+ const { setKey, viewerKey } = this.generateLocalVideoViewerKeys(ip, videoId)
+
+ return Promise.all([
+ this.addToSet(setKey, viewerKey),
+ this.setObject(viewerKey, object)
+ ])
+ }
+
+ listLocalVideoViewerKeys () {
+ const { setKey } = this.generateLocalVideoViewerKeys()
+
+ return this.getSet(setKey)
+ }
+
+ deleteLocalVideoViewersKeys (key: string) {
+ const { setKey } = this.generateLocalVideoViewerKeys()
+
+ return Promise.all([
+ this.deleteFromSet(setKey, key),
+ this.deleteKey(key)
+ ])
+ }
+
+ /* ************ Resumable uploads final responses ************ */
+
+ setUploadSession (uploadId: string, response?: { video: { id: number, shortUUID: string, uuid: string } }) {
+ return this.setValue(
+ 'resumable-upload-' + uploadId,
+ response
+ ? JSON.stringify(response)
+ : '',
+ RESUMABLE_UPLOAD_SESSION_LIFETIME
+ )
+ }
+
+ doesUploadSessionExist (uploadId: string) {
+ return this.exists('resumable-upload-' + uploadId)
+ }
+
+ async getUploadSession (uploadId: string) {
+ const value = await this.getValue('resumable-upload-' + uploadId)
+
+ return value
+ ? JSON.parse(value)
+ : ''
+ }
+
+ deleteUploadSession (uploadId: string) {
+ return this.deleteKey('resumable-upload-' + uploadId)
+ }
+
+ /* ************ AP resource unavailability ************ */
+
+ async addAPUnavailability (url: string) {
+ const key = this.generateAPUnavailabilityKey(url)
+
+ const value = await this.increment(key)
+ await this.setExpiration(key, AP_CLEANER.PERIOD * 2)
+
+ return value