Wednesday, October 22, 2014

Redis notes

KEYS * - Returns all keys matching pattern.
FLUSHDB - Delete all the keys of the currently selected DB
FLUSHALL - Delete all the keys of all the existing databases, not just the currently selected one.


Hashes

Hashes are maps between string fields and string values, so they are the perfect data type to represent objects
(eg: A User with a number of fields like name, surname, age, and so forth)
HGETALL key - lists all fields


Sets

Sets are an unordered collection of Strings.
SMEMBERS key - Get all the members in a set


Sorted Sets

Sorted Sets are, similarly to Redis Sets, non repeating collections of Strings. The difference is that every member of a Sorted Set is associated with score, that is used in order to take the sorted set ordered, from the smallest to the greatest score. While members are unique, scores may be repeated.
ZCARD key - Get the number of members in a sorted set
ZRANGE key start stop [WITHSCORES] - Return a range of members in a sorted set, by index

Ref:
Redis homepage
Redis for the real world (IBM - Java development 2.0)

No comments:

Post a Comment