Stores messages in the public cache by priority
556802
public function swrite($severity, $value='')
    {
        if(sizeof($this->cache) == $this->messageLimit) {
            array_shift($this->cache);
        }
        $this->cache[] = $value;
    }
1210683
function(){
    if(this.cache === NIL){ return void 0; }
    this.cache = NIL;
    for (var i = 0, l = this.subscribers.length; i < l; i++) {
      this.subscribers[i].isLazyValue && this.subscribers[i].makeDirty();
    }
  }
747102
def update_counter_cache
      self.discussion.reply_count = Post.where(:discussion_id => self.discussion.id)
                                        .count - 1
      self.discussion.save
    end
371005
private function _cleanCache()
    {
        if ($this->cache instanceof \Zend_Cache_Core) {
            $this->cache->clean();
            $this->addMessage($this->_('Cache cleaned'));
        }
    }
1030515
def _update_priority(self, task, prio, worker):
        
        task.priority = prio = max(prio, task.priority)
        for dep in task.deps or []:
            t = self._state.get_task(dep)
            if t is not None and prio > t.priority:
                self._update_priority(t, prio, worker)
632310
public void addMessage(Message message) {
        synchronized (messages) {
            api.addMessageToCache(message);
            if (messages.stream().map(Reference::get).anyMatch(message::equals)) {
                return;
            }
            // Add the message in the correct order
            messages.removeIf(messageRef -> messageRef.get() == null);
            Reference<Message> messageRef = new SoftReference<>(message, messagesCleanupQueue);
            int pos = Collections.binarySearch(messages, messageRef, Comparator.comparing(Reference::get));
            if (pos < 0) {
                pos = -pos - 1;
            }
            messages.add(pos, messageRef);
        }
    }
860175
protected void putToRingBuffer(IQueueMessage<ID, DATA> msg) throws QueueException.QueueIsFull {
        if (msg == null) {
            throw new NullPointerException("Supplied queue message is null!");
        }
        LOCK_PUT.lock();
        try {
            if (!ringBuffer.tryPublishEvent((event, _seq) -> {
                event.set(msg);
                knownPublishedSeq = _seq > knownPublishedSeq ? _seq : knownPublishedSeq;
            })) {
                throw new QueueException.QueueIsFull(getRingSize());
            }
        } finally {
            LOCK_PUT.unlock();
        }
    }
112812
def Flush(self):
    """"""

    self.data_store.StoreRequestsAndResponses(
        new_requests=self.request_queue,
        new_responses=self.response_queue,
        requests_to_delete=self.requests_to_delete)

    # We need to make sure that notifications are written after the requests so
    # we flush after writing all requests and only notify afterwards.
    mutation_pool = self.data_store.GetMutationPool()
    with mutation_pool:

      messages_by_queue = collection.Group(
          list(itervalues(
              self.client_messages_to_delete)), lambda request: request.queue)
      for queue, messages in iteritems(messages_by_queue):
        self.Delete(queue, messages, mutation_pool=mutation_pool)

      if self.new_client_messages:
        for timestamp, messages in iteritems(
            collection.Group(self.new_client_messages, lambda x: x[1])):

          self.Schedule([x[0] for x in messages],
                        timestamp=timestamp,
                        mutation_pool=mutation_pool)

    if self.notifications:
      for notification in itervalues(self.notifications):
        self.NotifyQueue(notification, mutation_pool=mutation_pool)

      mutation_pool.Flush()

    self.request_queue = []
    self.response_queue = []
    self.requests_to_delete = []

    self.client_messages_to_delete = {}
    self.notifications = {}
    self.new_client_messages = []
997015
def prioritize():
    

    while True:
        hp_qs = Message.objects.high_priority().using('default')
        mp_qs = Message.objects.medium_priority().using('default')
        lp_qs = Message.objects.low_priority().using('default')
        while hp_qs.count() or mp_qs.count():
            while hp_qs.count():
                for message in hp_qs.order_by("when_added"):
                    yield message
            while hp_qs.count() == 0 and mp_qs.count():
                yield mp_qs.order_by("when_added")[0]
        while hp_qs.count() == 0 and mp_qs.count() == 0 and lp_qs.count():
            yield lp_qs.order_by("when_added")[0]
        if Message.objects.non_deferred().using('default').count() == 0:
            break
1122487
def QueueMessages(self, messages):
    """"""
    # Push all the messages to our input queue
    for message in messages:
      self._in_queue.put(message, block=True)
536831
function getCumulativeMessages(timestamp, clientSync) {
    var msgs = [];
    if (lastSync > clientSync) {
        msgs = messages;
    } else {
        var newMsgs = messages.length;
        while (newMsgs > 0 && messages[newMsgs - 1].timestamp > timestamp) {
            newMsgs--;
        }
        for (var i = newMsgs; i < messages.length; i++) {
            msgs.push(messages[i]);
        }
    }

    var data = {};
    data.msgs = msgs;
    data.lastSync = lastSync;

    return data;
}
333458
public void pushMessages(List<byte[]> messages) {
    for (byte[] message: messages) {
      this.futures.offer(producer.send(new ProducerRecord<>(topic, message), (recordMetadata, e) -> {
        if (e != null) {
          log.error("Failed to send message to topic {} due to exception: ", topic, e);
        }
      }));
    }

    //Once the low watermark of numFuturesToBuffer is hit, start flushing messages from the futures
    // buffer. In order to avoid blocking on newest messages added to futures queue, we only invoke future.get() on
    // the oldest messages in the futures buffer. The number of messages to flush is same as the number of messages added
    // in the current call. Note this does not completely avoid calling future.get() on the newer messages e.g. when
    // multiple threads enter the if{} block concurrently, and invoke flush().
    if (this.futures.size() >= this.numFuturesToBuffer) {
      flush(messages.size());
    }
  }
835952
def _store(self, message_key: str, result: Result, ttl: int) -> None:  # pragma: no cover
        
        raise NotImplementedError("%(classname)r does not implement _store()" % {
            "classname": type(self).__name__,
        })
516259
def priority(self, item):
        
        return '%.1f' % max(self.cache[item.pk][0] / self.max_entries, 0.1)
443961
function(threadId, messageContent) {
                var message = formatDataToMakeMessage(threadId, messageContent);

                /**
                 * Update Message on cache
                 */
                if (canUseCache) {
                    if (db) {
                        try {
                            var tempData = {},
                                salt = Utility.generateUUID();
                            tempData.id = parseInt(message.id);
                            tempData.owner = parseInt(userInfo.id);
                            tempData.threadId = parseInt(message.threadId);
                            tempData.time = message.time;
                            tempData.message = Utility.crypt(message.message, cacheSecret, salt);
                            tempData.data = Utility.crypt(JSON.stringify(unsetNotSeenDuration(message)), cacheSecret, salt);
                            tempData.salt = salt;

                            /**
                             * Insert Message into cache database
                             */
                            db.messages.put(tempData)
                                .catch(function(error) {
                                    fireEvent('error', {
                                        code: error.code,
                                        message: error.message,
                                        error: error
                                    });
                                });
                        }
                        catch (error) {
                            fireEvent('error', {
                                code: error.code,
                                message: error.message,
                                error: error
                            });
                        }
                    }
                    else {
                        fireEvent('error', {
                            code: 6601,
                            message: CHAT_ERRORS[6601],
                            error: null
                        });
                    }
                }

                fireEvent('messageEvents', {
                    type: 'MESSAGE_EDIT',
                    result: {
                        message: message
                    }
                });
            }
196966
private void updateReadyness()
	{
		StringBuffer _buffer = new StringBuffer();
		if (null == myMessageProvider)
		{
			_buffer.append(NO_MESSAGE_PROVIDER);
		}
		if (null == myIconProvider)
		{
			if (_buffer.length() > 0)
			{
				_buffer.append(COMMA);
			}
			_buffer.append(NO_ICON_PROVIDER);
		}
		if (_buffer.length() > 0)
		{
			_buffer.append(DOT);
		}
		myReasonWhyNotReady = _buffer.toString();
		myIsReady = (_buffer.length() == 0);

	}
255609
function cache(source) {
    var _err = Nil
    var _value = Nil
    var _result = null
    var listeners = null

    return function continuable(callback) {
        if (_err !== Nil || _value !== Nil) {
            callback(_err, _value)
        } else if (listeners) {
            listeners.push(callback)
        } else {
            listeners = [callback]
            _result = source(function (err, value) {
                _err = err
                _value = value

                listeners.forEach(function (l) { l(err, value) })
            })
        }

        return _result
    }
}