First, import the jar package
Second, realize simple conditional query
Create a User entity class
Create 5 objects and put them in the cache so we can test them
When queried in redis, you can see that 5 user objects have been stored in the cache
Next, first implement a single-condition query, such as querying a user with an age of 15 and a user with a gender of m Since Redis is nosql and cannot directly use where to query conditions like mysql, Redis can only use a stupid method to implement conditional query: save all qualified users in a set
So, if you want to query the user with an age of 15, you need to first remove all the UUIDs from the USER_TABLE_AGE_15, and then remove the user from the USER_TABLE
The results are as follows:
User [id=63a970ec-e997-43e0-8ed9-14c5eb87de8b, name=y1, sex=m, age=15] User [id=aa074a2a-88d9-4b50-a99f-1375539164f7, name=y4, sex=n, age=15] So if you need a user with an age of 15 and a gender of M, it's very simple, get it USER_TABLE_AGE_15 and USER_TABLE_SEX_m, and then obtain them from the USER_TABLE.
User [id=63a970ec-e997-43e0-8ed9-14c5eb87de8b, name=y1, sex=m, age=15]
|