etag write to file

handle query before db loaded
This commit is contained in:
thuanle
2024-07-14 00:48:58 +07:00
parent 12603bbf6c
commit eaeb32b421
4 changed files with 39 additions and 7 deletions

View File

@@ -8,7 +8,8 @@ import (
import reader "github.com/oschwald/maxminddb-golang"
type IpDb struct {
r *reader.Reader
r *reader.Reader
mu sync.RWMutex
}
var (
@@ -25,6 +26,9 @@ func Ins() *IpDb {
}
func (d *IpDb) Reload() error {
d.mu.Lock()
defer d.mu.Unlock()
if d.r != nil {
_ = d.r.Close()
}
@@ -37,3 +41,7 @@ func (d *IpDb) Reload() error {
d.r = r
return nil
}
func (d *IpDb) IsLoaded() bool {
return d.r != nil
}