This commit is contained in:
Andrew Naylor 2013-07-01 00:49:23 +01:00
Родитель e81cf5b7bc
Коммит 0cf06aa40e
2 изменённых файлов: 12 добавлений и 1 удалений

Просмотреть файл

@ -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].
### 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'
`function (error) { }`

Просмотреть файл

@ -383,6 +383,13 @@ Connection.prototype.socketClosed = function(socket) {
this.serviceBuffer();
};
/**
* Use this method to modify the cache length after initialisation.
*/
Connection.prototype.setCacheLength = function(newLength) {
this.options.cacheLength = newLength;
};
/**
* @private
*/
@ -397,7 +404,7 @@ Connection.prototype.cacheNotification = function (socket, notification) {
socket.cachedNotifications.push(notification);
if (socket.cachedNotifications.length > this.options.cacheLength) {
debug("Clearing notification %d from the cache", socket.cachedNotifications[0]['_uid']);
socket.cachedNotifications.shift();
socket.cachedNotifications.splice(0, socket.cachedNotifications.length - this.options.cacheLength);
}
};