1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-20 01:08:35 +00:00

Retry create issue to cope with duplicate keys (#7898)

* Retry create issue to cope with duplicate keys

* Use  .SetExpr().Where().Insert()
This commit is contained in:
guillep2k
2019-08-26 23:17:23 -03:00
committed by techknowlogick
parent 541fab196f
commit 5fe2ec264f
39 changed files with 1991 additions and 1404 deletions

16
vendor/xorm.io/core/cache.go generated vendored
View File

@@ -14,19 +14,20 @@ import (
)
const (
// default cache expired time
// CacheExpired is default cache expired time
CacheExpired = 60 * time.Minute
// not use now
// CacheMaxMemory is not use now
CacheMaxMemory = 256
// evey ten minutes to clear all expired nodes
// CacheGcInterval represents interval time to clear all expired nodes
CacheGcInterval = 10 * time.Minute
// each time when gc to removed max nodes
// CacheGcMaxRemoved represents max nodes removed when gc
CacheGcMaxRemoved = 20
)
// list all the errors
var (
ErrCacheMiss = errors.New("xorm/cache: key not found.")
ErrNotStored = errors.New("xorm/cache: not stored.")
ErrCacheMiss = errors.New("xorm/cache: key not found")
ErrNotStored = errors.New("xorm/cache: not stored")
)
// CacheStore is a interface to store cache
@@ -69,6 +70,7 @@ func decodeIds(s string) ([]PK, error) {
return pks, err
}
// GetCacheSql returns cacher PKs via SQL
func GetCacheSql(m Cacher, tableName, sql string, args interface{}) ([]PK, error) {
bytes := m.GetIds(tableName, GenSqlKey(sql, args))
if bytes == nil {
@@ -77,6 +79,7 @@ func GetCacheSql(m Cacher, tableName, sql string, args interface{}) ([]PK, error
return decodeIds(bytes.(string))
}
// PutCacheSql puts cacher SQL and PKs
func PutCacheSql(m Cacher, ids []PK, tableName, sql string, args interface{}) error {
bytes, err := encodeIds(ids)
if err != nil {
@@ -86,6 +89,7 @@ func PutCacheSql(m Cacher, ids []PK, tableName, sql string, args interface{}) er
return nil
}
// GenSqlKey generates cache key
func GenSqlKey(sql string, args interface{}) string {
return fmt.Sprintf("%v-%v", sql, args)
}