mmkal / handy-redis

A wrapper around node_redis with Promise and TypeScript support.
Apache License 2.0
172 stars 10 forks source link

ERR syntax error when using SET #357

Open haziqfiqri opened 2 years ago

haziqfiqri commented 2 years ago

os: Windows_NT 10.0.19042 x64 v0.30.6 version: 2.3.1 redis: 3.2.100 node: 12.13.0

os: mac version: 2.3.1 redis: v=6.2.6 sha=00000000:0 malloc=libc bits=64 build=c6f3693d1aced7d9 node: 14.16.0

I have this piece of code which acts as an interceptor in the controller level which run fine on mac but not on my windows pc. Can verify why this is happening?

code:

async intercept(
        context: ExecutionContext,
        next: CallHandler,
    ): Promise<Observable<unknown>> {
        const request = context.switchToHttp().getRequest<Request>();
        const projectId = request.body['project']?.id;

        const expirySeconds = parseInt(process.env.REDIS_CACHE_SEC);
        const expiryKey = `${projectId}:expiry`;
        const dataKey = `${projectId}:data`;
        const pxAt = new Date().getTime() + expirySeconds * 1000;

        const data = await this.redisClient.set(
            dataKey,
            '1',
            ['PXAT', pxAt],
            'GET',
        );

        if (!data) {
            await this.redisClient.set(expiryKey, pxAt.toString(), [
                'PXAT',
                pxAt,
            ]);
            return next.handle();
        }

        return of([]);
    }

error:

"ReplyError: ERR syntax error\n at parseError (C:\\Users\\User\\Desktop\\project\\node_modules\\redis-parser\\lib\\parser.js:179:12)\n at parseType (C:\\Users\\User\\Desktop\\project\\node_modules\\redis-parser\\lib\\parser.js:302:14)"