chore: custom error

This commit is contained in:
2026-03-02 13:39:34 +01:00
parent abfddca518
commit 19b9532f21
21 changed files with 364 additions and 61 deletions
+5 -5
View File
@@ -14,7 +14,7 @@ const keyStat = "webdav:stat:"
// CachedClient wraps a FileSystem implementation with Valkey caching.
type CachedClient struct {
impl FS
client valkey.Client
cache valkey.Client
ttl time.Duration
hits atomic.Int64
misses atomic.Int64
@@ -25,9 +25,9 @@ type CachedClient struct {
// NewCachedClient creates a new CachedClient.
func NewCachedClient(impl FS, client valkey.Client, refreshtime time.Duration) *CachedClient {
c := &CachedClient{
impl: impl,
client: client,
ttl: refreshtime * 5,
impl: impl,
cache: client,
ttl: refreshtime * 5,
}
go func() {
@@ -50,7 +50,7 @@ func (c *CachedClient) revalidate(ctx context.Context) {
func (c *CachedClient) scanAndProcess(ctx context.Context, match string, process func(key string) error) {
cursor := uint64(0)
for {
res, err := c.client.Do(ctx, c.client.B().Scan().Cursor(cursor).Match(match).Build()).AsScanEntry()
res, err := c.cache.Do(ctx, c.cache.B().Scan().Cursor(cursor).Match(match).Build()).AsScanEntry()
if err != nil {
slog.Error("scan failed", "match", match, "err", err)
return