33 lines
522 B
Go
33 lines
522 B
Go
package storage
|
|
|
|
import "fmt"
|
|
|
|
type MemoryStorage struct {
|
|
Data map[string]any
|
|
}
|
|
|
|
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
|
|
}
|
|
return nil, fmt.Errorf("value does not exist")
|
|
}
|
|
|
|
func (ms *MemoryStorage) Set(k string, v any) error {
|
|
ms.Data[k] = v
|
|
return nil
|
|
}
|
|
|
|
func (ms *MemoryStorage) GetData() any {
|
|
return ms.Data
|
|
}
|