mirror of
https://github.com/gofiber/storage.git
synced 2025-10-05 08:37:10 +08:00
🦴 update skeleton
This commit is contained in:
@@ -4,6 +4,7 @@ import "time"
|
||||
|
||||
// Storage interface that is implemented by storage providers
|
||||
type Storage struct {
|
||||
gcInterval time.Duration
|
||||
}
|
||||
|
||||
// New creates a new storage
|
||||
@@ -16,10 +17,15 @@ func New(config ...Config) *Storage {
|
||||
cfg = configDefault(config[0])
|
||||
}
|
||||
|
||||
// TODO
|
||||
_ = cfg
|
||||
// Create storage
|
||||
store := &Storage{
|
||||
gcInterval: cfg.GCInterval,
|
||||
}
|
||||
|
||||
return &Storage{}
|
||||
// Start garbage collector
|
||||
go store.gc()
|
||||
|
||||
return store
|
||||
}
|
||||
|
||||
// Get value by key
|
||||
@@ -41,3 +47,12 @@ func (s *Storage) Delete(key string) error {
|
||||
func (s *Storage) Clear() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Garbage collector to delete expired keys
|
||||
func (s *Storage) gc() {
|
||||
tick := time.NewTicker(s.gcInterval)
|
||||
for {
|
||||
<-tick.C
|
||||
// clean entries
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user