question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`ERR syntax error` when using set

See original GitHub issue
  • Version: node_redis: ^2.8.0 redis-server: Redis server v=4.0.1 sha=00000000:0 malloc=libc bits=64 build=f37081b32886670b

  • Platform: Node.js v8.3.0 Darwin 16.7.0 Darwin Kernel Version 16.7.0: Thu Jun 15 17:36:27 PDT 2017; root:xnu-3789.70.16~2/RELEASE_X86_64 x86_64

  • Description: set will result in ERR syntax error:

const redis = require('redis'),
      Promise = require('bluebird'),
      conf = require(__root_dir + '/conf/conf')

// Promise.promisifyAll(redis.RedisClient.prototype)
// Promise.promisifyAll(redis.Multi.prototype)
const client = redis.createClient(
    conf.redis.port,
    conf.redis.host)

const key = 'sess-test'
const uid = 1
const ttl = 60 * 60 * 24 * 30
client.set(key, uid, ttl)

will generate

Send localhost:6379 id 0: *4
$3
set
$9
sess-test
$1
1
$7
2592000

Net read localhost:6379 id 0
Error ReplyError: ERR syntax error

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
BridgeARcommented, Aug 30, 2017

Please check the readme. You have to add ‘EX’ or ‘PX’ depending on what type of timeout you want.

1reaction
stockholmuxcommented, Mar 30, 2020

@atuttle That’s not quite right. Node_redis just relays the commands to Redis. What you’re wanting to do is this for inline setting of the TTL client.set(key, value,'EX', ttl, callback), as per the SET command’s documentation.

Additionally, the client.ttl() command gets the time to live not sets it. If you want to do it set the TTL you have to use client.expire().

Read more comments on GitHub >

github_iconTop Results From Across the Web

`ERR syntax error` when using set · Issue #1269 - GitHub
ERR syntax error when using set #1269 ... I was trying to do a set with an inline TTL: redis.set(key, value, ttl, callback)...
Read more >
Getting "ERR syntax error" on set using node-redis
I think if you want to properly bind client.get you should do util.promisify(client.get.bind(client)) - ie this is the reference to the client.
Read more >
Fix “ERR syntax error” when using the SISINTERCARD ...
If you're getting an error that reads “ERR syntax error” when using the SINTERCARD command, it could be because your first argument is...
Read more >
Graphing Calculator - Fix Syntax Error - YouTube
Quickly fix a syntax error on a graphing calculator.
Read more >
Re: ERR syntax error while getting the a member with highest ...
whenever i execute the following line (with or without pipelining) i get a "ERR syntax error" Set<Tuple> set = jedis.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found