mirror of
https://github.com/Mrs4s/go-cqhttp.git
synced 2025-05-04 19:17:37 +08:00
db/sqlite: use ParseDuration
This commit is contained in:
parent
40e4f40525
commit
0b106d8ef5
@ -11,6 +11,7 @@ import (
|
|||||||
|
|
||||||
sql "github.com/FloatTech/sqlite"
|
sql "github.com/FloatTech/sqlite"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
|
|
||||||
"github.com/Mrs4s/MiraiGo/binary"
|
"github.com/Mrs4s/MiraiGo/binary"
|
||||||
@ -28,7 +29,7 @@ type database struct {
|
|||||||
// config mongodb 相关配置
|
// config mongodb 相关配置
|
||||||
type config struct {
|
type config struct {
|
||||||
Enable bool `yaml:"enable"`
|
Enable bool `yaml:"enable"`
|
||||||
CacheTTL time.Duration `yaml:"cachettl"`
|
CacheTTL string `yaml:"cachettl"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@ -39,7 +40,11 @@ func init() {
|
|||||||
if !conf.Enable {
|
if !conf.Enable {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return &database{db: new(sql.Sqlite), ttl: conf.CacheTTL * time.Millisecond}
|
duration, err := time.ParseDuration(conf.CacheTTL)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("illegal ttl config: %v", err)
|
||||||
|
}
|
||||||
|
return &database{db: new(sql.Sqlite), ttl: duration}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user