mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
Expose vips internal cache settings and status
This commit is contained in:
16
README.md
16
README.md
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user