setCacheLength method.
This commit is contained in:
Родитель
e81cf5b7bc
Коммит
0cf06aa40e
|
@ -119,6 +119,10 @@ If you wish to send notifications containing emoji or other multi-byte character
|
||||||
|
|
||||||
If in doubt, leave the encoding as default. If you experience any problems post a question in the [node-apn Google Group][googlegroup].
|
If in doubt, leave the encoding as default. If you experience any problems post a question in the [node-apn Google Group][googlegroup].
|
||||||
|
|
||||||
|
### connection.setCacheLength(newLength)
|
||||||
|
|
||||||
|
Used to manually adjust the "cacheLength" property in the options. This is ideal if you choose to use the `cacheTooSmall` event to tweak your environment. It is safe for increasing and reducing cache size.
|
||||||
|
|
||||||
### Event: 'error'
|
### Event: 'error'
|
||||||
|
|
||||||
`function (error) { }`
|
`function (error) { }`
|
||||||
|
|
|
@ -383,6 +383,13 @@ Connection.prototype.socketClosed = function(socket) {
|
||||||
this.serviceBuffer();
|
this.serviceBuffer();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use this method to modify the cache length after initialisation.
|
||||||
|
*/
|
||||||
|
Connection.prototype.setCacheLength = function(newLength) {
|
||||||
|
this.options.cacheLength = newLength;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
|
@ -397,7 +404,7 @@ Connection.prototype.cacheNotification = function (socket, notification) {
|
||||||
socket.cachedNotifications.push(notification);
|
socket.cachedNotifications.push(notification);
|
||||||
if (socket.cachedNotifications.length > this.options.cacheLength) {
|
if (socket.cachedNotifications.length > this.options.cacheLength) {
|
||||||
debug("Clearing notification %d from the cache", socket.cachedNotifications[0]['_uid']);
|
debug("Clearing notification %d from the cache", socket.cachedNotifications[0]['_uid']);
|
||||||
socket.cachedNotifications.shift();
|
socket.cachedNotifications.splice(0, socket.cachedNotifications.length - this.options.cacheLength);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче