Expose vips internal cache settings and status

This commit is contained in:
Lovell Fuller
2014-02-25 23:31:33 +00:00
parent ae9a8b0f57
commit d5d85a8697
6 changed files with 44 additions and 3 deletions

View File

@@ -51,7 +51,7 @@ Scale and crop to `width` x `height` calling `callback` when complete.
`callback` gets two arguments `(err, buffer)` where `err` is an error message, if any, and `buffer` is the resultant image data when a Buffer is requested.
### Examples
#### Examples
```javascript
sharp.resize("input.jpg", "output.jpg", 300, 200, function(err) {
@@ -101,6 +101,20 @@ sharp.resize("input.jpg", sharp.buffer.webp, 200, 300, {canvas: sharp.canvas.emb
});
```
### cache([limit])
If `limit` is provided, set the `vips` internal cache limit to this value in MB. The default value is 100.
Always returns cache statistics, namely current usage, high water mark and maximum limit.
The high water mark may be higher than the maximum limit.
```javascript
var stats = sharp.cache(); // { current: 98, high: 115, limit: 100 }
sharp.cache(200); // { current: 98, high: 115, limit: 200 }
sharp.cache(50); // { current: 49, high: 115, limit: 50 }
```
## Testing
npm test