🐛 Fix status expired in cache

This commit is contained in:
LittleSheep 2024-06-26 20:08:18 +08:00
parent 132d301aeb
commit 7c0713a12f
2 changed files with 17 additions and 12 deletions

View File

@ -4,15 +4,8 @@
<option name="autoReloadType" value="ALL" />
</component>
<component name="ChangeListManager">
<list default="true" id="3fefb2c4-b6f9-466b-a523-53352e8d6f95" name="更改" comment=":sparkles: Can pick up mfa request">
<change afterPath="$PROJECT_DIR$/pkg/internal/server/api/statuses_api.go" afterDir="false" />
<change afterPath="$PROJECT_DIR$/pkg/internal/services/statuses.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/models/statuses.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/models/statuses.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/server/api/index.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/server/api/index.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/services/accounts.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/services/accounts.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/services/factors.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/services/factors.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/services/notifications.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/services/notifications.go" afterDir="false" />
<list default="true" id="3fefb2c4-b6f9-466b-a523-53352e8d6f95" name="更改" comment=":sparkles: Status system">
<change beforePath="$PROJECT_DIR$/pkg/internal/services/statuses.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/services/statuses.go" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -126,6 +119,14 @@
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="3" />
</component>
<component name="UnknownFeatures">
<option featureType="dependencySupport" implementationName="javascript:npm:prettier" />
<option featureType="dependencySupport" implementationName="executable:docker" />
<option featureType="dependencySupport" implementationName="javascript:npm:unocss" />
<option featureType="dependencySupport" implementationName="javascript:npm:vite" />
<option featureType="dependencySupport" implementationName="executable:kubectl" />
<option featureType="dependencySupport" implementationName="javascript:npm:vue" />
</component>
<component name="Vcs.Log.Tabs.Properties">
<option name="TAB_STATES">
<map>
@ -150,7 +151,6 @@
</option>
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value=":sparkles: Able to read current user's realm profile" />
<MESSAGE value=":sparkles: Consul registration" />
<MESSAGE value=":wastebasket: Remove HTTP provision to consul" />
<MESSAGE value=":sparkles: Drop direct connection and uses consul" />
@ -175,7 +175,8 @@
<MESSAGE value=":card_file_box: Add the status model" />
<MESSAGE value=":bug: Authenticate wrong payload hotfix" />
<MESSAGE value=":sparkles: Can pick up mfa request" />
<option name="LAST_COMMIT_MESSAGE" value=":sparkles: Can pick up mfa request" />
<MESSAGE value=":sparkles: Status system" />
<option name="LAST_COMMIT_MESSAGE" value=":sparkles: Status system" />
</component>
<component name="VgoProject">
<settings-migrated>true</settings-migrated>

View File

@ -20,7 +20,11 @@ func NewStatus(user models.Account, status models.Status) (models.Status, error)
func GetStatus(uid uint) (models.Status, error) {
if status, ok := statusCache[uid]; ok {
return status, nil
if status.ClearAt != nil && status.ClearAt.Before(time.Now()) {
delete(statusCache, uid)
} else {
return status, nil
}
}
var status models.Status
if err := database.C.