Skip to content

Commit

Permalink
fix: first set the LRU usage flag to false
Browse files Browse the repository at this point in the history
  • Loading branch information
fufuok committed Mar 22, 2024
1 parent 85b6c7d commit f2561fa
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion web/fiber/middleware/blacklist.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ var (

// UseBlacklistCache 重新设置黑名单检查时缓存, 配置变化时可选再次调用, 由应用端 Start() Runtime() 调用
func UseBlacklistCache(capacity, lifetime uint64) (err error) {
useBlacklistLRU.Store(false)
if capacity == 0 {
return nil
}
Expand All @@ -30,7 +31,6 @@ func UseBlacklistCache(capacity, lifetime uint64) (err error) {
return err
}

useBlacklistLRU.Store(false)
blacklistLRU = lru
useBlacklistLRU.Store(blacklistLRU != nil)
return nil
Expand Down
2 changes: 1 addition & 1 deletion web/fiber/middleware/whitelist.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ var (

// UseWhitelistCache 重新设置白名单检查时缓存, 配置变化时可选再次调用, 由应用端 Start() Runtime() 调用
func UseWhitelistCache(capacity, lifetime uint64) error {
useWhitelistLRU.Store(false)
if capacity == 0 {
return nil
}
Expand All @@ -35,7 +36,6 @@ func UseWhitelistCache(capacity, lifetime uint64) error {
return err
}

useWhitelistLRU.Store(false)
whitelistLRU = lru
useWhitelistLRU.Store(whitelistLRU != nil)
return nil
Expand Down
2 changes: 1 addition & 1 deletion web/gin/middleware/blacklist.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ var (

// UseBlacklistCache 重新设置黑名单检查时缓存, 配置变化时可选再次调用, 由应用端 Start() Runtime() 调用
func UseBlacklistCache(capacity, lifetime uint64) (err error) {
useBlacklistLRU.Store(false)
if capacity == 0 {
return nil
}
Expand All @@ -29,7 +30,6 @@ func UseBlacklistCache(capacity, lifetime uint64) (err error) {
return err
}

useBlacklistLRU.Store(false)
blacklistLRU = lru
useBlacklistLRU.Store(blacklistLRU != nil)
return nil
Expand Down
2 changes: 1 addition & 1 deletion web/gin/middleware/whitelist.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ var (

// UseWhitelistCache 重新设置白名单检查时缓存, 配置变化时可选再次调用, 由应用端 Start() Runtime() 调用
func UseWhitelistCache(capacity, lifetime uint64) error {
useWhitelistLRU.Store(false)
if capacity == 0 {
return nil
}
Expand All @@ -34,7 +35,6 @@ func UseWhitelistCache(capacity, lifetime uint64) error {
return err
}

useWhitelistLRU.Store(false)
whitelistLRU = lru
useWhitelistLRU.Store(whitelistLRU != nil)
return nil
Expand Down

0 comments on commit f2561fa

Please sign in to comment.