Skip to content

Commit

Permalink
fscache: add placeholder [WIP]
Browse files Browse the repository at this point in the history
Signed-off-by: Alejandro Mery <[email protected]>
  • Loading branch information
amery committed Jan 13, 2024
1 parent 56ac0de commit f7f89c4
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cache.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
{
"path": "."
},
{
"path": "x/fscache"
},
{
"path": "x/groupcache"
},
Expand Down
19 changes: 19 additions & 0 deletions x/fscache/LICENCE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright 2023 JPI Technologies Ltd <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
Empty file added x/fscache/README.md
Empty file.
44 changes: 44 additions & 0 deletions x/fscache/fscache.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Package fscache implements a cache over fs.FS
package fscache

import (
"context"
"sync"
"time"

"darvaza.org/cache"
"darvaza.org/slog"
)

var (
_ cache.Store = (*Store)(nil)
_ cache.Cache = (*Cache)(nil)
)

type Store struct {
mu sync.Mutex
log slog.Logger
m map[string]*Cache
}

func (s *Store) SetLogger(log slog.Logger) {}

func (s *Store) DeregisterCache(name string) {}

func (s *Store) GetCache(name string) cache.Cache {}

func (s *Store) NewCache(name string, cacheBytes int64, getter cache.Getter) cache.Cache {}

type Cache struct {
mu sync.Mutex
name string
store *Store
}

func (g *Cache) Name() string { return g.name }
func (g *Cache) Stats(t cache.Type) cache.Stats

func (g *Cache) Get(ctx context.Context, key string, dest cache.Sink) error {}
func (g *Cache) Set(ctx context.Context, key string, data []byte, expire time.Time, cacheType cache.Type) error {
}
func (g *Cache) Remove(ctx context.Context, key string) {}
15 changes: 15 additions & 0 deletions x/fscache/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module darvaza.org/cache/x/fscache

go 1.19

require (
darvaza.org/cache v0.2.1
darvaza.org/slog v0.5.2
)

require (
darvaza.org/core v0.9.4 // indirect
golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1 // indirect
golang.org/x/net v0.12.0 // indirect
golang.org/x/text v0.11.0 // indirect
)
12 changes: 12 additions & 0 deletions x/fscache/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
darvaza.org/cache v0.2.1 h1:zu8aIPhp+NhQk/CWt83qaUBaTN35bVYjBPU01ByP3TE=
darvaza.org/cache v0.2.1/go.mod h1:BJmVYj1dmYMWsuuGA7Htn2JmoCLoAV+MWtEv5lLs0Gw=
darvaza.org/core v0.9.4 h1:HYKmYiWehDtqATF0vBv2i/DvdpNP7YJPu3pOW7h0CWI=
darvaza.org/core v0.9.4/go.mod h1:O3tHBMlw+xB47uGh5CUx7dXAujBAMmD8BCRFPZmIw54=
darvaza.org/slog v0.5.2 h1:8TG1WyHjOyh2vW6t3pjzZVaWzpko5MIIpeI7LWqHFvs=
darvaza.org/slog v0.5.2/go.mod h1:HAkEpxTA/mkiLNUXJo5qsCh8EVCtA3evje8GAaCDWHI=
golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1 h1:MGwJjxBy0HJshjDNfLsYO8xppfqWlA5ZT9OhtUUhTNw=
golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc=
golang.org/x/net v0.12.0 h1:cfawfvKITfUsFCeJIHJrbSxpeu/E81khclypR0GVT50=
golang.org/x/net v0.12.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA=
golang.org/x/text v0.11.0 h1:LAntKIrcmeSKERyiOh0XMV39LXS8IE9UL2yP7+f5ij4=
golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=

0 comments on commit f7f89c4

Please sign in to comment.