Your cart is currently empty!
Category: redis
-
Khóa học miễn phí Redis – Hashes nhận dự án làm có lương
Redis – Hashes
Redis Hashes are maps between the string fields and the string values. Hence, they are the perfect data type to represent objects.
In Redis, every hash can store up to more than 4 billion field-value pairs.
Example
redis 127.0.0.1:6379> HMSET tutorialspoint name "redis tutorial" description "redis basic commands for caching" likes 20 visitors 23000 OK redis 127.0.0.1:6379> HGETALL tutorialspoint 1) "name" 2) "redis tutorial" 3) "description" 4) "redis basic commands for caching" 5) "likes" 6) "20" 7) "visitors" 8) "23000"
In the above example, we have set Redis tutorials detail (name, description, likes, visitors) in hash named ‘tutorialspoint’.
Redis Hash Commands
Following table lists some basic commands related to hash.
Sr.No Command & Description 1 Deletes one or more hash fields.
2 Determines whether a hash field exists or not.
3 Gets the value of a hash field stored at the specified key.
4 Gets all the fields and values stored in a hash at the specified key
5 Increments the integer value of a hash field by the given number
6 Increments the float value of a hash field by the given amount
7 Gets all the fields in a hash
8 Gets the number of fields in a hash
9 Gets the values of all the given hash fields
10 Sets multiple hash fields to multiple values
11 Sets the string value of a hash field
12 Sets the value of a hash field, only if the field does not exist
13 Gets all the values in a hash
14 Incrementally iterates hash fields and associated values
Khóa học lập trình tại Toidayhoc vừa học vừa làm dự án vừa nhận lương: Khóa học lập trình nhận lương tại trung tâm Toidayhoc
Khóa học miễn phí Redis – Sorted Sets nhận dự án làm có lương
Redis – Sorted Sets
Redis Sorted Sets are similar to Redis Sets with the unique feature of values stored in a set. The difference is, every member of a Sorted Set is associated with a score, that is used in order to take the sorted set ordered, from the smallest to the greatest score.
In Redis sorted set, add, remove, and test for the existence of members in O(1) (constant time regardless of the number of elements contained inside the set). Maximum length of a list is 232 – 1 elements (4294967295, more than 4 billion of elements per set).
Example
redis 127.0.0.1:6379> ZADD tutorials 1 redis (integer) 1 redis 127.0.0.1:6379> ZADD tutorials 2 mongodb (integer) 1 redis 127.0.0.1:6379> ZADD tutorials 3 mysql (integer) 1 redis 127.0.0.1:6379> ZADD tutorials 3 mysql (integer) 0 redis 127.0.0.1:6379> ZADD tutorials 4 mysql (integer) 0 redis 127.0.0.1:6379> ZRANGE tutorials 0 10 WITHSCORES 1) "redis" 2) "1" 3) "mongodb" 4) "2" 5) "mysql" 6) "4"
In the above example, three values are inserted with its score in Redis sorted set named ‘tutorials’ by the command ZADD.
Redis Sorted Sets Commands
Following table lists some basic commands related to sorted sets.
Sr.No | Command & Description |
---|---|
1 |
Adds one or more members to a sorted set, or updates its score, if it already exists |
2 |
Gets the number of members in a sorted set |
3 |
Counts the members in a sorted set with scores within the given values |
4 |
Increments the score of a member in a sorted set |
5 |
Intersects multiple sorted sets and stores the resulting sorted set in a new key |
6 |
Counts the number of members in a sorted set between a given lexicographical range |
7 |
Returns a range of members in a sorted set, by index |
8 |
Returns a range of members in a sorted set, by lexicographical range |
9 |
Returns a range of members in a sorted set, by score |
10 |
Determines the index of a member in a sorted set |
11 |
Removes one or more members from a sorted set |
12 |
Removes all members in a sorted set between the given lexicographical range |
13 |
Removes all members in a sorted set within the given indexes |
14 |
Removes all members in a sorted set within the given scores |
15 |
Returns a range of members in a sorted set, by index, with scores ordered from high to low |
16 |
Returns a range of members in a sorted set, by score, with scores ordered from high to low |
17 |
Determines the index of a member in a sorted set, with scores ordered from high to low |
18 |
Gets the score associated with the given member in a sorted set |
19 |
Adds multiple sorted sets and stores the resulting sorted set in a new key |
20 |
Incrementally iterates sorted sets elements and associated scores |
Khóa học lập trình tại Toidayhoc vừa học vừa làm dự án vừa nhận lương: Khóa học lập trình nhận lương tại trung tâm Toidayhoc