aboutsummaryrefslogtreecommitdiff
path: root/lib/anify/info.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/anify/info.js')
-rw-r--r--lib/anify/info.js13
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/anify/info.js b/lib/anify/info.js
index 8978664..e7d4025 100644
--- a/lib/anify/info.js
+++ b/lib/anify/info.js
@@ -1,5 +1,5 @@
import axios from "axios";
-import cacheData from "memory-cache";
+import redis from "../redis";
export async function fetchInfo(id, key) {
try {
@@ -15,13 +15,18 @@ export async function fetchInfo(id, key) {
export default async function getAnifyInfo(id, key) {
try {
- const cached = cacheData.get(id);
+ let cached;
+ if (redis) {
+ cached = await redis.get(id);
+ }
if (cached) {
- return cached;
+ return JSON.parse(cached);
} else {
const data = await fetchInfo(id, key);
if (data) {
- cacheData.put(id, data, 1000 * 60 * 10);
+ if (redis) {
+ await redis.set(id, JSON.stringify(data), "EX", 60 * 10);
+ }
return data;
} else {
return { message: "Schedule not found" };