LoadFromCache implements imagor.Cacher. w and h are the requested output dimensions used to determine cache eligibility, not to select a blob of that size. Returns (nil, false) when w or h is zero (unknown size) or exceeds CacheMaxWidth×CacheMaxHeight — the cache holds a downscaled copy and cannot s
(key string, w, h int)
| 35 | // Returns (nil, false) when w or h is zero (unknown size) or exceeds CacheMaxWidth×CacheMaxHeight |
| 36 | // — the cache holds a downscaled copy and cannot safely serve those requests. |
| 37 | func (v *Processor) LoadFromCache(key string, w, h int) (*imagor.Blob, bool) { |
| 38 | if v.cache == nil || w <= 0 || h <= 0 { |
| 39 | return nil, false |
| 40 | } |
| 41 | if w > v.CacheMaxWidth || h > v.CacheMaxHeight { |
| 42 | return nil, false |
| 43 | } |
| 44 | return v.cache.Get(key) |
| 45 | } |
| 46 | |
| 47 | // loadOrCache returns a cached blob for the given image path, using the image cache. |
| 48 | // Cache key is image path only, so the same source serves all requested sizes. |