Home > Database > Redis > What is the difference between redis and simple map?

What is the difference between redis and simple map?

(*-*)浩
Release: 2019-08-10 15:35:07
Original
3737 people have browsed it

The difference between cache

What is the difference between redis and simple map?

##Cache is divided into local cache and distributed cache. (Recommended learning:

Redis video tutorial)

Take java as an example, using the built-in map or guava to implement local caching. The main features are lightweight and fast. , the life cycle ends with the destruction of the jvm, and in the case of multiple instances, each instance needs to save its own cache, and the cache is not consistent.

Using redis or memcached is called distributed cache. In the case of multiple instances, each instance shares a cache of data, and the cache is consistent. The disadvantage is that the redis or memcached service needs to be kept highly available, and the entire program architecture is relatively complex.

Of course, if you only save a small amount of data as a cache and there is no need for persistence, you can use Map as a cache.

What is the difference between redis and simple map:

1.

Redis can use dozens of G memory for caching, but Map cannot, and the general JVM only Dividing the data into several G is enough.

2.

Redis’ cache can be persisted. Map is a memory object, and the data will be gone as soon as the program is restarted.

3.

Redis can implement distributed caching. Map can only exist in the program that created it.

4.

Redis can handle millions of concurrency per second and is a professional cache service, Map is just an ordinary object

5,

Redis cache has an expiration mechanism, Map itself does not have this function

6,

Redis has a rich API, Map is too simple

For more Redis-related technical articles, please visit the

Redis database usage tutorial column to learn !

The above is the detailed content of What is the difference between redis and simple map?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template