본문 바로가기

1.프로그래밍/DB

[Redis] WRONGTYPE Operation against a key holding the wrong kind of value

728x90
반응형

[Redis] WRONGTYPE Operation against a key holding the wrong kind of value

레디스에 데이터를 집어 넣고 데이터를 조회하려 했다.


opsForSet을 통해 Set을 이용하여 데이터를 관리하려고 했다.


그런데, 위와 같은 에러가 뜨면서 조회가 되질 않았다.


찾아보니, 레디스에도 데이터 타입이 존재하고, Set의 경우 smembers key 형식으로 가져올 수 있다고 한다.


Redis support 5 types of data types. You need to know what type of value that key maps to, as for each data type, the command to retrieve it is different.

Here are the commands to retrieve key value:

if value is of type string -> GET
if value is of type hash -> HGETALL
if value is of type lists -> lrange
if value is of type sets -> smembers
if value is of type sorted sets -> ZRANGEBYSCORE
command to check the type of value a key mapping to:

type


내가 넣어놓은 데이터의 타입을 알고싶다면 type key 를 사용해서 타입을 확인하자

728x90
반응형