first prototype of the thumbnail service
Currently uses in memory caching and loads the file from the local filesystem.
This commit is contained in:
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
package cache
|
||||
|
||||
import (
|
||||
"image"
|
||||
)
|
||||
|
||||
// Cache defines the interface for a thumbnail cache.
|
||||
type Cache interface {
|
||||
Get(key string) image.Image
|
||||
Set(key string, thumbnail image.Image) (image.Image, error)
|
||||
}
|
||||
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
package cache
|
||||
|
||||
// TODO: implement filesystem cache for longer persistence
|
||||
Vendored
+22
@@ -0,0 +1,22 @@
|
||||
package cache
|
||||
|
||||
import "image"
|
||||
|
||||
func NewInMemoryCache() InMemoryCache {
|
||||
return InMemoryCache{
|
||||
store: make(map[string]image.Image),
|
||||
}
|
||||
}
|
||||
|
||||
type InMemoryCache struct {
|
||||
store map[string]image.Image
|
||||
}
|
||||
|
||||
func (fsc InMemoryCache) Get(key string) image.Image {
|
||||
return fsc.store[key]
|
||||
}
|
||||
|
||||
func (fsc InMemoryCache) Set(key string, thumbnail image.Image) (image.Image, error) {
|
||||
fsc.store[key] = thumbnail
|
||||
return thumbnail, nil
|
||||
}
|
||||
Reference in New Issue
Block a user