Skip to content

Commit

Permalink
fixed some deletions
Browse files Browse the repository at this point in the history
  • Loading branch information
lonelycode committed Aug 12, 2024
1 parent 8ac1e07 commit cb56832
Showing 1 changed file with 2 additions and 59 deletions.
61 changes: 2 additions & 59 deletions temporal/internal/driver/local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,72 +50,15 @@ func NewLocalStore(connector model.Connector) *API {
// init the key indexes
api.Store.Set(keyIndexKey, &Object{
Type: TypeList,
Value: map[string]bool{},
Value: map[string]interface{}{},
NoExp: true,
})

api.Store.Set(deletedKeyIndexKey, &Object{
Type: TypeList,
Value: map[string]bool{},
Value: map[string]interface{}{},
NoExp: true,
})

return api
}

func (api *API) addToKeyIndex(key string) error {
o, err := api.Store.Get(keyIndexKey)
if err != nil {
// not found, create new
o = &Object{
Type: TypeSet,
Value: map[string]bool{key: true},
NoExp: true,
}

return api.Store.Set(keyIndexKey, o)
}

if o == nil {
o = &Object{
Type: TypeSet,
Value: map[string]bool{key: true},
NoExp: true,
}
}

list := o.Value.(map[string]bool)
list[key] = true

o.Value = list

return api.Store.Set(keyIndexKey, o)
}

func (api *API) updateDeletedKeysIndex(key string) error {
o, err := api.Store.Get(deletedKeyIndexKey)
if err != nil {
// not found, create new
o = &Object{
Type: TypeSet,
Value: map[string]bool{key: true},
NoExp: true,
}

return api.Store.Set(deletedKeyIndexKey, o)
}

if o == nil {
o = &Object{
Type: TypeSet,
Value: map[string]bool{key: true},
NoExp: true,
}
}

list := o.Value.(map[string]bool)
list[key] = true
o.Value = list

return api.Store.Set(deletedKeyIndexKey, o)
}

0 comments on commit cb56832

Please sign in to comment.