各位大神,这个是面试题啊,小弟是菜鸟,最好,用比较通俗的话说,最好不要直接 百度copy 其他人的,最好是自己处理总结过的,因为,本人已经百度了很多次了。
大家讲道理2017-04-24 09:15:02
It is a non-relational database (NoSQL) written in C/C++. The characteristics of redis:
Uses simple data or key-indexed hash tables, but also supports complex operations such as ZREVRANGEBYSCORE.
INCR & co (suitable for calculating extreme values or statistical data)
Supports sets (also supports union/diff/inter)
Supports list (also supports queue; blocking pop operation)
Supports hash tables (objects with multiple fields)
Support sorting sets (high score table, suitable for range queries)
Redis supports transactions
Supports setting data to expired data (similar to fast buffer design)
Pub/Sub allows users to implement messaging mechanisms
As for what it is used for or how to use it:
In terms of general limitations, Redis also exists in the form of a message queue and as an embedded List to meet real-time high concurrency requirements. Usually in an e-commerce type data processing process, the queues of related products, hot sales, and recommended sorting are usually stored in Redis, and the reading and updating of the Redis list by Storm is also included in the process.
You can refer to this article: Redis application scenarios
黄舟2017-04-24 09:15:02
Redis is a memory kv storage, which is somewhat similar to memcache and can often be interchanged. Generally used to add a layer of cache in front of the database.
For example, for a simple members table, the members table may need to be read for each request. Frequent reads can be cached using redis.
row=redis->get("m_"..id)
if not row then
sql="select * from members where id='"..id.."'";
row=sdo:fetch(sql);
redis->set("m_"..id,row);
end
This is the basic one and the most used one.
Redis also has queues. For example, if a request records a user's operation request, use redis->lpush(op) to add it to the queue from the left. A background service can read from the redis queue, op=redis->rpop(op), this can complete a simple first-come, first-served policy.
In addition, redis can also be persisted, that is, the kv data in the memory is saved to the hard disk, and can be loaded from the memory after a power outage.
Personally, I do not recommend using redis persistence. Turn off persistence and just use it as a cache.