Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
陈曦
sub2api
Commits
a16f72f5
Commit
a16f72f5
authored
Jan 10, 2026
by
yangjianbo
Browse files
fix(认证): 订阅兑换失效认证缓存
订阅兑换后同步失效认证缓存避免授权快照滞后 补充单测覆盖订阅兑换的失效场景 测试: go test ./... -tags=unit
parent
99e2391b
Changes
2
Hide whitespace changes
Inline
Side-by-side
backend/internal/service/auth_cache_invalidation_test.go
View file @
a16f72f5
...
@@ -26,6 +26,8 @@ func TestRedeemService_InvalidateRedeemCaches_AuthCache(t *testing.T) {
...
@@ -26,6 +26,8 @@ func TestRedeemService_InvalidateRedeemCaches_AuthCache(t *testing.T) {
svc
.
invalidateRedeemCaches
(
context
.
Background
(),
11
,
&
RedeemCode
{
Type
:
RedeemTypeBalance
})
svc
.
invalidateRedeemCaches
(
context
.
Background
(),
11
,
&
RedeemCode
{
Type
:
RedeemTypeBalance
})
svc
.
invalidateRedeemCaches
(
context
.
Background
(),
11
,
&
RedeemCode
{
Type
:
RedeemTypeConcurrency
})
svc
.
invalidateRedeemCaches
(
context
.
Background
(),
11
,
&
RedeemCode
{
Type
:
RedeemTypeConcurrency
})
groupID
:=
int64
(
3
)
svc
.
invalidateRedeemCaches
(
context
.
Background
(),
11
,
&
RedeemCode
{
Type
:
RedeemTypeSubscription
,
GroupID
:
&
groupID
})
require
.
Equal
(
t
,
[]
int64
{
11
,
11
},
invalidator
.
userIDs
)
require
.
Equal
(
t
,
[]
int64
{
11
,
11
,
11
},
invalidator
.
userIDs
)
}
}
backend/internal/service/redeem_service.go
View file @
a16f72f5
...
@@ -348,6 +348,9 @@ func (s *RedeemService) invalidateRedeemCaches(ctx context.Context, userID int64
...
@@ -348,6 +348,9 @@ func (s *RedeemService) invalidateRedeemCaches(ctx context.Context, userID int64
return
return
}
}
case
RedeemTypeSubscription
:
case
RedeemTypeSubscription
:
if
s
.
authCacheInvalidator
!=
nil
{
s
.
authCacheInvalidator
.
InvalidateAuthCacheByUserID
(
ctx
,
userID
)
}
if
s
.
billingCacheService
==
nil
{
if
s
.
billingCacheService
==
nil
{
return
return
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment