corebasic 1.0.153 → 1.0.154
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/libs/messaging.js +13 -0
- package/package.json +1 -1
package/libs/messaging.js
CHANGED
|
@@ -114,6 +114,19 @@ export async function produce(channel, message) {
|
|
|
114
114
|
}
|
|
115
115
|
|
|
116
116
|
|
|
117
|
+
|
|
118
|
+
export async function set(key, value) {
|
|
119
|
+
await defaultConsumer.set(`${process.env.REDIS_CHANNEL_PREFIX}_${key}`, typeof value === 'object' ? JSON.stringify(value) : value)
|
|
120
|
+
}
|
|
121
|
+
export async function get(key) {
|
|
122
|
+
let value = await defaultConsumer.get(`${process.env.REDIS_CHANNEL_PREFIX}_${key}`)
|
|
123
|
+
try { value = JSON.parse(value) } catch(err) { }
|
|
124
|
+
return value
|
|
125
|
+
}
|
|
126
|
+
export async function del(key) {
|
|
127
|
+
await defaultConsumer.del(`${process.env.REDIS_CHANNEL_PREFIX}_${key}`)
|
|
128
|
+
}
|
|
129
|
+
|
|
117
130
|
// Hydrate
|
|
118
131
|
|
|
119
132
|
export async function hydrate(callback) {
|