feat: updated pkg implementations
This commit is contained in:
parent
86f37555b2
commit
8b161135ff
10 changed files with 579 additions and 140 deletions
|
|
@ -2,10 +2,22 @@ package storage
|
|||
|
||||
type DiskStorage struct{}
|
||||
|
||||
func (ds *DiskStorage) Read(k string) error {
|
||||
func (ds DiskStorage) Init() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ms *DiskStorage) Write(k string, v any) error {
|
||||
func (ds DiskStorage) Cleanup() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ds DiskStorage) Get(k string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ds DiskStorage) Set(k string, v any) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ds DiskStorage) GetData() any {
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,16 @@ type MemoryStorage struct {
|
|||
Data map[string]any
|
||||
}
|
||||
|
||||
func (ms *MemoryStorage) Read(k string) (any, error) {
|
||||
func (ms *MemoryStorage) Init() error {
|
||||
ms.Data = map[string]any{}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ms *MemoryStorage) Cleanup() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ms *MemoryStorage) Get(k string) (any, error) {
|
||||
v, ok := ms.Data[k]
|
||||
if ok {
|
||||
return v, nil
|
||||
|
|
@ -14,7 +23,11 @@ func (ms *MemoryStorage) Read(k string) (any, error) {
|
|||
return nil, fmt.Errorf("value does not exist")
|
||||
}
|
||||
|
||||
func (ms *MemoryStorage) Write(k string, v any) error {
|
||||
func (ms *MemoryStorage) Set(k string, v any) error {
|
||||
ms.Data[k] = v
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ms *MemoryStorage) GetData() any {
|
||||
return ms.Data
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,18 @@
|
|||
package storage
|
||||
|
||||
type KVStore interface {
|
||||
Init() error
|
||||
Cleanup() error
|
||||
|
||||
Get(k string) (any, error)
|
||||
Set(k string, v any) error
|
||||
GetData() any
|
||||
}
|
||||
|
||||
type KVStaticStore[T any] interface {
|
||||
Init() error
|
||||
Cleanup() error
|
||||
|
||||
Get(k string) (T, error)
|
||||
Set(k string, v T) error
|
||||
GetData() T
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue