@@ -16,7 +16,7 @@ import (
16
16
"time"
17
17
18
18
"github.com/go-pkgz/jrpc"
19
- "github.com/go-pkgz/lcw/eventbus"
19
+ "github.com/go-pkgz/lcw/v2/ eventbus"
20
20
log "github.com/go-pkgz/lgr"
21
21
ntf "github.com/go-pkgz/notify"
22
22
"github.com/golang-jwt/jwt"
@@ -28,7 +28,7 @@ import (
28
28
"github.com/go-pkgz/auth/provider"
29
29
"github.com/go-pkgz/auth/provider/sender"
30
30
"github.com/go-pkgz/auth/token"
31
- cache "github.com/go-pkgz/lcw"
31
+ cache "github.com/go-pkgz/lcw/v2 "
32
32
33
33
"github.com/umputun/remark42/backend/app/migrator"
34
34
"github.com/umputun/remark42/backend/app/notify"
@@ -869,27 +869,28 @@ func (s *ServerCommand) makeAdminStore() (admin.Store, error) {
869
869
870
870
func (s * ServerCommand ) makeCache () (LoadingCache , error ) {
871
871
log .Printf ("[INFO] make cache, type=%s" , s .Cache .Type )
872
+ o := cache .NewOpts [[]byte ]()
872
873
switch s .Cache .Type {
873
874
case "redis_pub_sub" :
874
875
redisPubSub , err := eventbus .NewRedisPubSub (s .Cache .RedisAddr , "remark42-cache" )
875
876
if err != nil {
876
877
return nil , fmt .Errorf ("cache backend initialization, redis PubSub initialisation: %w" , err )
877
878
}
878
- backend , err := cache .NewLruCache (cache .MaxCacheSize (s .Cache .Max .Size ), cache .MaxValSize (s .Cache .Max .Value ),
879
- cache .MaxKeys (s .Cache .Max .Items ), cache .EventBus (redisPubSub ))
879
+ backend , err := cache .NewLruCache (o .MaxCacheSize (s .Cache .Max .Size ), o .MaxValSize (s .Cache .Max .Value ),
880
+ o .MaxKeys (s .Cache .Max .Items ), o .EventBus (redisPubSub ))
880
881
if err != nil {
881
882
return nil , fmt .Errorf ("cache backend initialization: %w" , err )
882
883
}
883
- return cache .NewScache (backend ), nil
884
+ return cache.NewScache [[] byte ] (backend ), nil
884
885
case "mem" :
885
- backend , err := cache .NewLruCache (cache .MaxCacheSize (s .Cache .Max .Size ), cache .MaxValSize (s .Cache .Max .Value ),
886
- cache .MaxKeys (s .Cache .Max .Items ))
886
+ backend , err := cache .NewLruCache (o .MaxCacheSize (s .Cache .Max .Size ), o .MaxValSize (s .Cache .Max .Value ),
887
+ o .MaxKeys (s .Cache .Max .Items ))
887
888
if err != nil {
888
889
return nil , fmt .Errorf ("cache backend initialization: %w" , err )
889
890
}
890
- return cache .NewScache (backend ), nil
891
+ return cache.NewScache [[] byte ] (backend ), nil
891
892
case "none" :
892
- return cache .NewScache (& cache.Nop {}), nil
893
+ return cache.NewScache [[] byte ] (& cache.Nop [[] byte ] {}), nil
893
894
}
894
895
return nil , fmt .Errorf ("unsupported cache type %s" , s .Cache .Type )
895
896
}
@@ -1326,11 +1327,12 @@ func splitAtCommas(s string) []string {
1326
1327
1327
1328
// authRefreshCache used by authenticator to minimize repeatable token refreshes
1328
1329
type authRefreshCache struct {
1329
- cache.LoadingCache
1330
+ cache.LoadingCache [ string ]
1330
1331
}
1331
1332
1332
1333
func newAuthRefreshCache () * authRefreshCache {
1333
- expirableCache , _ := cache .NewExpirableCache (cache .TTL (5 * time .Minute ))
1334
+ o := cache .NewOpts [string ]()
1335
+ expirableCache , _ := cache .NewExpirableCache (o .TTL (5 * time .Minute ))
1334
1336
return & authRefreshCache {LoadingCache : expirableCache }
1335
1337
}
1336
1338
@@ -1341,5 +1343,5 @@ func (c *authRefreshCache) Get(key interface{}) (interface{}, bool) {
1341
1343
1342
1344
// Set implements cache setter with key converted to string
1343
1345
func (c * authRefreshCache ) Set (key , value interface {}) {
1344
- _ , _ = c .LoadingCache .Get (key .(string ), func () (interface {} , error ) { return value , nil })
1346
+ _ , _ = c .LoadingCache .Get (key .(string ), func () (string , error ) { return value .( string ) , nil })
1345
1347
}
0 commit comments