chitchat/server/storage/storage.go

25 lines
572 B
Go
Raw Normal View History

2025-01-05 16:28:42 +00:00
package storage
import "errors"
var (
ErrNotExists = errors.New("not exists")
)
type Store interface {
// Checks if the storage has an element with the id.
// Returns [ErrNotExists] if the element doesn't exist.
Has(id string) error
// Retreive an element from the storage.
// Returns [ErrNotExists] if the element doesn't exist.
Get(id string) ([]byte, error)
// Store an element in the storage.
Put(id string, element []byte) error
// Delete an element from the storage.
// Returns [ErrNotExists] if the elment doesn't exist.
Delete(id string) error
}