seaweedfs/weed/util/skiplist/list_store.go

33 lines
638 B
Go
Raw Normal View History

2021-10-03 17:19:21 +08:00
package skiplist
type ListStore interface {
SaveElement(id int64, element *SkipListElement) error
DeleteElement(id int64) error
LoadElement(id int64) (*SkipListElement, error)
}
type MemStore struct {
m map[int64]*SkipListElement
}
func newMemStore() *MemStore {
return &MemStore{
m: make(map[int64]*SkipListElement),
}
}
func (m *MemStore) SaveElement(id int64, element *SkipListElement) error {
m.m[id] = element
return nil
}
func (m *MemStore) DeleteElement(id int64) error {
delete(m.m, id)
return nil
}
func (m *MemStore) LoadElement(id int64) (*SkipListElement, error) {
element := m.m[id]
return element, nil
}