How to be in linux Upper use redis：
Last article , Introduced how to in linux Installation on redis, So how do we use it . stay redi In the case of startup redis-cli command , As shown in the figure ：
every last redis Service contains 16 Databases , Subscript 0-15. If we're going to redis When you put in the data , Do not specify Library , So by default 0 library , Let's take a look at how to store data into a specified database
perform select index command （index Subscript to the database ）, For example, I want to switch to a subscript of 2 The database of , So , After switching, there will be one more 2 The logo of ：
Let's see how to use it redis The order of , Input help command , As shown in the figure below ：
Here's how to get through help To learn redis The order of ,help @<group> It means you can see redis Each group's command ,Redis There are plenty of orders , The command groups included are Cluster、Connection、Geo、Hashes、HyperLogLog、Keys、Lists、Pub/Sub、Scripting、Server、Sets、Sorted Sets、Strings、Transactions altogether 14 individual redis More than 200 command groups redis command , If you want to know more , Reference resources http://www.redis.cn/commands.html.help You can also follow the command you want to know , You can also use tab Automatic completion , It is also pointed out here that through quit You can quit redis client .
redis A brief introduction to the data types of ：
- Strings： Binary safe string .
- Lists: A collection of string elements sorted by insertion order . They are basically Linked list （linked lists）.
- Sets: A collection of unrepeated and unordered string elements .
- Sorted sets, similar Sets, But each string element is associated with a string element called score Floating values （floating number value）. The elements in it always pass through score Sort it out , So the difference is , It's a series of elements that can be retrieved .（ For example, you might ask ： Give me the front 10 One or the back 10 Elements ）.
- Hashes, from field Associated with value Composed of map.field and value It's all strings . This sum Ruby、Python Of hashes It's like .
- Bit arrays ( Or say simply bitmaps): By special orders , You can take String Value as a series of bits Handle ： You can set and clear individual bits, Count all of them set to 1 Of bits The number of , The first one found is set to 1 or 0 Of bit, wait .
- HyperLogLogs: Is used to estimate a set The number of elements in the probability of the data structure .