init test
This commit is contained in:
22
convex/actions/redis.ts
Normal file
22
convex/actions/redis.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
'use node';
|
||||
|
||||
import { query, mutation, action } from "../_generated/server";
|
||||
import { Kevisual } from '@kevisual/ai/browser'
|
||||
import { v } from "convex/values";
|
||||
import { Redis } from "ioredis";
|
||||
const redisClient = new Redis({
|
||||
host: process.env.REDIS_HOST,
|
||||
password: process.env.REDIS_PASSWORD,
|
||||
});
|
||||
let time: any = null;
|
||||
export const isConnected = action({
|
||||
args: {},
|
||||
handler: async (ctx) => {
|
||||
const result = await redisClient.ping();
|
||||
if (time === null) {
|
||||
time = new Date();
|
||||
}
|
||||
console.log("Redis PING at", new Date().toISOString(), "since", time);
|
||||
return result === "PONG";
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user