feature: initial syndication feeds support
[oweals/peertube.git] / server / lib / redis.ts
index b284cab8fde5ed45c6d47e4573c7322473a4a53f..41f4c986989c0d5754ad5f48abfbd23122008c74 100644 (file)
@@ -23,7 +23,7 @@ class Redis {
     })
 
     this.client.on('error', err => {
-      logger.error('Error in Redis client.', err)
+      logger.error('Error in Redis client.', { err })
       process.exit(-1)
     })
 
@@ -54,6 +54,16 @@ class Redis {
     return this.exists(this.buildViewKey(ip, videoUUID))
   }
 
+  listJobs (jobsPrefix: string, state: string, mode: 'alpha', order: 'ASC' | 'DESC', offset: number, count: number) {
+    return new Promise<string[]>((res, rej) => {
+      this.client.sort(jobsPrefix + ':jobs:' + state, 'by', mode, order, 'LIMIT', offset.toString(), count.toString(), (err, values) => {
+        if (err) return rej(err)
+
+        return res(values)
+      })
+    })
+  }
+
   private getValue (key: string) {
     return new Promise<string>((res, rej) => {
       this.client.get(this.prefix + key, (err, value) => {