Monorepo for Tangled
at 51c7db9c7fefd83c0b5cc2cfc473c517ee9d07a2 23 lines 338 B view raw
1package cursor 2 3import ( 4 "sync" 5) 6 7type MemoryStore struct { 8 store sync.Map 9} 10 11func (m *MemoryStore) Set(knot string, cursor int64) { 12 m.store.Store(knot, cursor) 13} 14 15func (m *MemoryStore) Get(knot string) (cursor int64) { 16 if result, ok := m.store.Load(knot); ok { 17 if val, ok := result.(int64); ok { 18 return val 19 } 20 } 21 22 return 0 23}