Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 33d1b2e0ee | |||
| 433cd1f8bc |
2
cache/redis/redis.go
vendored
2
cache/redis/redis.go
vendored
@@ -59,6 +59,6 @@ func New(dsn string, hashRadix string) *RedisClient {
|
||||
|
||||
func Hash(s string) int {
|
||||
h := fnv.New32a()
|
||||
h.Write([]byte(s))
|
||||
h.Write([]byte(strings.ToLower(s)))
|
||||
return int(h.Sum32()) % vars.RedisShardings
|
||||
}
|
||||
|
||||
@@ -8,6 +8,20 @@ import (
|
||||
"gorm.io/gorm/schema"
|
||||
)
|
||||
|
||||
func SetOptions(options *types.SqlOptions) *types.SqlOptions {
|
||||
if options == nil {
|
||||
options = &types.SqlOptions{
|
||||
MaxIdleConns: vars.SqlOptionMaxIdleConns,
|
||||
MaxOpenConns: vars.SqlOptionMaxIdleConns,
|
||||
ConnMaxLifetime: vars.SqlOptionConnMaxLifetime,
|
||||
LogStdout: false,
|
||||
Debug: false,
|
||||
}
|
||||
}
|
||||
|
||||
return options
|
||||
}
|
||||
|
||||
// new grom db.
|
||||
func NewPostgreSql(dsn string, options *types.SqlOptions) (*gorm.DB, error) {
|
||||
var err error
|
||||
|
||||
Reference in New Issue
Block a user