Refactored redis usage. Added lib/cache.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import prisma from 'lib/prisma';
|
||||
import redis from 'lib/redis';
|
||||
import cache from 'lib/cache';
|
||||
|
||||
export async function createWebsite(userId, data) {
|
||||
return prisma.client.website
|
||||
@@ -13,11 +13,11 @@ export async function createWebsite(userId, data) {
|
||||
...data,
|
||||
},
|
||||
})
|
||||
.then(async res => {
|
||||
if (redis.enabled && res) {
|
||||
await redis.set(`website:${res.id}`, res);
|
||||
.then(async data => {
|
||||
if (cache.enabled) {
|
||||
await cache.storeWebsite(data);
|
||||
}
|
||||
|
||||
return res;
|
||||
return data;
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user