summaryrefslogtreecommitdiff
path: root/internal/router/client-cache.go
diff options
from:
to:
context:
space:
mode:
authorGravatar SayaAndy <saya.andy@posteo.com> 2025-10-25 18:53:30 +0700
committerGravatar SayaAndy <saya.andy@posteo.com> 2025-10-25 18:53:30 +0700
commit427ab1a9a4d6094d9f3a84e62f09cc396b49a09b (patch)
tree83535f9d535921cff7739c0166b9494cd7eb2217 /internal/router/client-cache.go
parentdf7a0ae1c0fc177cba2eae8cc73fe21d2afdd229 (diff)
downloadweb-427ab1a9a4d6094d9f3a84e62f09cc396b49a09b.tar.gz
web-427ab1a9a4d6094d9f3a84e62f09cc396b49a09b.zip
fix: make sure db transactions end always
Diffstat (limited to 'internal/router/client-cache.go')
-rw-r--r--internal/router/client-cache.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/internal/router/client-cache.go b/internal/router/client-cache.go
index d607cdd..26557d0 100644
--- a/internal/router/client-cache.go
+++ b/internal/router/client-cache.go
@@ -110,7 +110,11 @@ func (c *ClientCache) Close() error {
return fmt.Errorf("fail to save blog_views: %s", err)
}
- return tx.Commit()
+ if err = tx.Commit(); err != nil {
+ tx.Rollback()
+ return fmt.Errorf("fail to commit all the changes related to cache: %s", err)
+ }
+ return nil
}
func (c *ClientCache) GetHash(id string) string {