feat(gallery): caching
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
package gallery
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"git.schreifuchs.ch/schreifuchs/schreifuchs.ch/internal/components/images"
|
||||
"git.schreifuchs.ch/schreifuchs/schreifuchs.ch/internal/pkg/config"
|
||||
"git.schreifuchs.ch/schreifuchs/schreifuchs.ch/internal/pkg/filesystem"
|
||||
"github.com/valkey-io/valkey-go"
|
||||
)
|
||||
|
||||
type getImager interface {
|
||||
@@ -11,15 +14,22 @@ type getImager interface {
|
||||
}
|
||||
|
||||
type Service struct {
|
||||
fs filesystem.FS
|
||||
cfg *config.Gallery
|
||||
img getImager
|
||||
fs filesystem.FS
|
||||
cfg *config.Gallery
|
||||
img getImager
|
||||
cache valkey.Client
|
||||
|
||||
refreshIntervall time.Duration
|
||||
}
|
||||
|
||||
func New(fs filesystem.FS, cfg *config.Gallery, img getImager) *Service {
|
||||
return &Service{
|
||||
fs: fs,
|
||||
cfg: cfg,
|
||||
img: img,
|
||||
func New(fs filesystem.FS, cfg *config.Gallery, img getImager, cache valkey.Client) *Service {
|
||||
s := &Service{
|
||||
fs: fs,
|
||||
cfg: cfg,
|
||||
img: img,
|
||||
cache: cache,
|
||||
}
|
||||
go s.autoRefresh()
|
||||
|
||||
return s
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user