MCPcopy Index your code
hub / github.com/cshum/imagor / LoadFromCache

Method LoadFromCache

processor/vipsprocessor/cache.go:37–45  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
37func (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.

Callers 1

TestProcessorFunction · 0.95

Implementers 4

cacherProcessorimagor_test.go
Processorprocessor/vipsprocessor/processor.go
testProcessorserver/server_test.go
slowTestProcessorserver/server_test.go

Calls 1

GetMethod · 0.65

Tested by 1

TestProcessorFunction · 0.76