Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ERR syntax error while performing SCAN operations in Redis using Spring Data Redis

While working with Redis using Spring Data Redis, I tried to scan hash data in my server (similar to HSCAN in CLI) -

Cursor<Entry<Object,Object>> scan = redisTemplate.opsForHash().scan("student", new ScanOptionsBuilder().count(0).match("*").build());

While running this I get the below error -

redis.clients.jedis.exceptions.JedisDataException: ERR syntax error

Can anyone help me how to solvw this.

There are many related discussions but none of them provide clear answer.

like image 363
shreyas.k Avatar asked Nov 20 '25 12:11

shreyas.k


1 Answers

You should use count > 0, or not using count at all (default is 10).

From looking at ScanOptions.java, if count is used, it is passed to the command without any checks.

A quick check on redis-cli shows COUNT 0 throws ERR syntax error.

> hset hash1 f v
(integer) 1
> hscan hash1 0 MATCH * COUNT 0
(error) ERR syntax error
> hscan hash1 0 MATCH * COUNT 1
1) "0"
2) 1) "f"
   2) "v"

See SCAN > The COUNT option for more details. It doesn't state it has to be greater than 0 though but makes sense it should.

like image 119
LeoMurillo Avatar answered Nov 22 '25 03:11

LeoMurillo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!