如何通过Redis中的通配符获取所有值?

假设我有以下的redis数据:

key               value

user-1-xxxx       data1

user-1-yyyy       data2

user-1-tttt       data3

那么,我是否可以通过通配符用户-1-(包括键和值)获得上述所有记录?

我试过KEYS user-1-*,但它只给出所有的键,而不是它们的值。

如果不支持通配符搜索,能推荐一种存储此类数据的方法吗?顺便说一下,我用的是金golang redigo。

Redis isn't designed for looking up data by value. You can either index the data yourself (see https://redis.io/topics/indexes) or use a search engine for that, such as http://redisearch.io.

You probably want to structure your data into a hash instead of single keys.

> HSET user-1 xxxx data1
> HSET user-1 yyyy data2
> HSET user-1 tttt data3

If you want to get everything on the user run HGETALL user-1 but if you just want to get a specific part, go for HGET user-1 xxx.