세션 무효화 처리 강화

This commit is contained in:
2024-02-21 12:08:33 +09:00
parent 0c5ddac9f5
commit 0ca764d6be
7 changed files with 101 additions and 49 deletions

View File

@ -10,13 +10,13 @@ import (
type cache_stage[T any] struct {
cache map[storagekey]T
deleted map[storagekey]bool
deleted map[storagekey]T
}
func make_cache_stage[T any]() *cache_stage[T] {
return &cache_stage[T]{
cache: make(map[storagekey]T),
deleted: make(map[storagekey]bool),
deleted: make(map[storagekey]T),
}
}
@ -39,14 +39,18 @@ func (c *consumer_common[T]) add_internal(sk storagekey, si T) {
func (c *consumer_common[T]) delete_internal(sk storagekey) (old T) {
if v, ok := c.stages[0].cache[sk]; ok {
old = v
c.stages[0].deleted[sk] = old
c.stages[1].deleted[sk] = old
delete(c.stages[0].cache, sk)
delete(c.stages[1].cache, sk)
} else if v, ok = c.stages[1].cache[sk]; ok {
old = v
c.stages[1].deleted[sk] = old
delete(c.stages[1].cache, sk)
}
c.stages[0].deleted[sk] = true
c.stages[1].deleted[sk] = true
return
}