This blog post mainly introduces the implementation of the simple chat room from the following two parts:1. Introduction to Redis Publish subscription mode2.java Code Implementation Subscription Publishing mode
One, Redis Publish subscription
Redis most commonly used data types are the following five: String Hash List Set Sorted set
Before describing these types of data, let's take a picture of how these different data types are described in Redis internal memory management:
First,
Redis is used as a cache in the most recent project, and the database is MongoDB. Project uses spring and everything works without introducing Redis, but add in Pom.xml:
org.springframework.boot
Spring-boot-starter-
1. First you need a message listener class
Package com.sogou.baike.testimport.testSubscribe;
Import Redis.clients.jedis.JedisPubSub;
/** * Created by Denglinjie on 2016/6/29. */public class Redismsgpubsublistener extends Jedispubsub {@Override
Run for a long time the environment unexpectedly can not log in, view the error of the newspaper, and Redis auth relationship, because the session of multiple servers exist Redis, Redis Connection failed to save the user's login sessions.
Preface:
In this blog, I will show you how to install Php-redis extensions on CENTOS7 and some simple and practical, about how to install Redis on CentOS, you can refer to my previous blog Redis installation deployment on CENTOS7
Want to operate
Personal notes are for informational purposes only.
1, spring data Redis recommended Jedis,jedis is a Redis Java client.
org.springframework.boot
spring-boot-starter-redis
2, redisconnectionfactory
The spring data Redis is
We have always known that Redis a few of the most commonly used data structures, strings, hashes, lists, sets, ordered sets. In fact, later Redis made a lot of supplements, one of which is Hyperloglog, the other is geo (geographical location), is 3.2
"Face question" redis-related
the difference between 1.Redis and memorycache.
Redis uses a single thread, while memcached is multi-threaded,
Redis stores data in a way that uses on-site memory, and can configure virtual memory; memcached uses a pre-
The master-slave architecture of Redis enables us to read more and write less, so it's easy to configure the Redis architecture below.
Prepare for the Environment VMware + rhel-server-7.0 (101,102,103) +redis-3.2.0
1, installed in 192.168.137.101
Pipelines and multiplexers
The delay is intolerable. Modern computers can generate data at an alarming rate, and high-speed Internet (often with multiple parallel connections between important servers) provides great bandwidth, but this nasty delay
RedisAdvantages of Redis:Support for multiple data structures, such as String (string), list (doubly linked list), Dict (hash table), set (set), Zset (sort set), Hyperloglog (cardinality estimation) support persistence operations, can be aof and RDB
1. Installing homebrew
What is homebrew?Official explanation:Homebrew is the simplest and most flexible way to install UNIX tools that Apple does not include in MacOS.Official website: PortalGit repository Address: Portal
How do I install the
Thank the Great God for sharing!Https://www.cnblogs.com/gdpuzxs/p/7222309.html(1) Pom.xml introduces the jar package as follows: org.springframework.boot Spring-boot-starter-data-redis (2) Modify the project
Redis Usage Basics (iv)--redis Sorting and message notification(Reproduced please attach this article link--linhxx)First, sort1. CommandSort key [ALPHA] [DESC] [LIMIT start end], sorts the list, collection, and ordered collection, and when the ALPHA
Redis clustered Redis cluster under windows:If you deploy to more than one computer, it is the same as a normal cluster; Because Redis is single-threaded, multicore CPUs can only use a single core,So on the same computer, you can increase CPU
the Java clients listed on the redis homepage are JDBC-redis Jedis. The following describes the advantages and disadvantages of the three clients and other related tools.
support for redis
Performance
maintenance
Exists key
Del key1 key2
Redis vauleRedis provides five data types: String, hash, list, set, and sorted set.
String is the most basic type, and the string type is binary secure. It indicates that the redis string can beContains any data. For example,
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service