set) is stored in the new collection
Zinterstore
Computes the intersection of one or more ordered sets given, where the number of a given key must be specified with the Numkeys parameter and the intersection (result set) is stored in the new collection
Zscan
Incremental iterations
Seven, Pub/subPub/sub Command Quick check:
Command
Description
Psubscribe
Subscribe to one or more channels that match a given pa
the processing of tasks.Of course, the most recommended way to use is: redis as a configuration, coordination, control center, with the disque queue service, the task needs to access the data as far as possible to store redis in.High Availability one master multi-slaveThe actuator executes at run time: Master single node runs, multiple slave do standby mechanism to guarantee the service availability. In fact, from the master downline to one of the slave, a successful campaign for master require
javascript-Observer pattern (Publish/subscribe)The observer pattern, also called the Publish-subscribe pattern, defines a one-to-many relationship that allows multiple observer objects to listen to a Subject object at the same time, notifying all observers when the subject's state changes. It is composed of two types of objects, subject and observer, the topic is responsible for publishing events, while observers subscribe to these events to observe the subject, the Publisher and Subscribers are
registeringAll of these three methods require a topic parameter because the Publisher may trigger multiple events (such as publishing a magazine and a newspaper at the same time) and the user may choose to subscribe to only one, not the other.Because these members are common to any Publisher object, it is meaningful to implement them as part of a separate object. That way we can copy it into any object and turn any given object into a publisher.JS in the implementation of the observer pattern i
requires you to know too much details about how those components communicate, in this way, the coupling between components is increased, and their cohesion and cohesion are reduced. this makes it difficult for your components to be reused in other applications.
By using the release/subscription design model, we can reduce the coupling between components and encapsulate the communication details between them. this will help increase the modularization, testability, and reusability of your compon
()); } break; System Message Case Basepack.system_push_pack: {systempushpack txtpack = new Systemp Ushpack (); Txtpack.touser = to; Txtpack.content = body; Txtpack.messageid = messageId; Target.acceptClient.Send (Txtpack.packtobytes ()); } break; Default: {} break; } }}And then there's the message queue and the PHP "-" Call problem between C #1. In strict accordance with the peer model and the
Example of publishing/subscribing to messages through JMS and example of subscribing to messages through jms
Based on the previous article "Tomcat + JNDI + ActiveMQ to implement JMS point-to-point message transmission", you can easily compile a publish/subscribe message transmission example. The environment preparation is similar to this article, the main differences are as follows.Configure JNDI in Tomcat
Configure the connection factory and topic
Compile code in the Web Factory
Create a pu
Python implements the redis subscription and publishing function, pythonredis
Redis is a key-value storage system. Similar to Memcached, Memcached supports more storage value types, including string, list, set, and zset) and hash (hash type ). The subscription and publishing system can also be implemented. Let's take a look at how to use redis and python to subscribe and publish,
Import redisclass RedisSubscri (): def _ init _ (self, host): self. coon = redis. redis (host = "127.0.0.1") def publ
actually poor, so the next v2 version will be available. The specific content of the upgrade will be introduced in the next article.1. Solve the distributed problem on the server sideThe core idea for solving this problem is relatively simple:Previously, we put event notifications in the process memory. Now we make network communication.Because the payment request volume is deployed with high concurrency, I gave up the idea of writing a notification server directly and checked whether there is
functionality of persistence and replication.5. Client support for different languagesMemcached and Redis have rich third-party clients to choose from for different language clients, but because memcached has been developing for a longer period of time, many of Memcached's clients are more mature and stable in terms of client support at present. and Redis because its protocol itself is more complex than memcached, plus the author constantly add new features, and so on, the corresponding third-p
calculation, pubsub, scripting, etc., for such functions need to understand its implementation principle, clearly understand its limitations, can be used correctly, such as pubsub function, This is actually not supported by any persistence, the consumer connection between the flash or the reconnection between the message is all lost, and such as aggregation calculation and scripting and other features are
functionality of persistence and replication.5. Client support for different languagesMemcached and Redis have rich third-party clients to choose from for different language clients, but because memcached has been developing for a longer period of time, many of Memcached's clients are more mature and stable in terms of client support at present. and Redis because its protocol itself is more complex than memcached, plus the author constantly add new features, and so on, the corresponding third-p
, pubsub, scripting, etc., for such functions need to understand its implementation principle, clearly understand its limitations, can be used correctly, such as pubsub function, This is actually not supported by any persistence, the consumer connection between the flash or the reconnection between the message is all lost, and such as aggregation calculation and scripting and other features are limited by t
functionality of persistence and replication.5. Client support for different languagesMemcached and Redis have rich third-party clients to choose from for different language clients, but because memcached has been developing for a longer period of time, many of Memcached's clients are more mature and stable in terms of client support at present. and Redis because its protocol itself is more complex than memcached, plus the author constantly add new features, and so on, the corresponding third-p
storage, Redis also provides some other functions, such as aggregation calculation, pubsub, scripting, etc., for such functions need to understand its implementation principle, clearly understand its limitations, can be used correctly. For example, the PubSub function, this is not any persistent support, consumer connection flash or reconnect after the message will be all lost, and such as aggregation calc
blocked, at the client code level for Jedispubsub when processing messages, will be "exclusive" link //and took a while loop, listening to messages for subscriptions // } }nbsP
public class Subclient {
private Jedis jedis;//public
subclient (String host,int port) {
Jedis = new Jedis (hos T,port);
}
public void Sub (Jedispubsub listener,string channel) {
jedis.subscribe (listener, channel);
This will block when the client code level is JEDISPUBSUB processing the message, it w
advantage in performance because the data is not written to disk.
In the above method the signal is broadcast, all in wait process will receive a signal, if you want to set the signal to unicast, only one of them to receive the signal, you can use the contract channel name mode to achieve, such as:
Channel name = channel name prefix (channel) + subscriber globally unique ID (myID)
The unique ID can be a UUID or a random number string to ensure that the global uniqueness is available. Use
Nodejs Redis Publish subscription mechanism encapsulation
Recent projects have used Redis to understand and encapsulate the use of publish and subscribe.
var config = require ('.. /config/config ');
var log = require ("./loghelp");
var Redis = require ("Redis");
function initialclient (param) {
var option={host:config.redis.host, port:config.redis.port};
if (param)
{
option=object.assign (option,param);
}
Redis.print Let
-client = redis.createclient (option);
Client.on
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.