mirror of
https://github.com/lionsoul2014/ip2region.git
synced 2025-12-08 19:25:22 +00:00
add cache policy parse func
This commit is contained in:
parent
1b9fb0c95c
commit
b44654230f
@ -7,6 +7,7 @@ package service
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/lionsoul2014/ip2region/binding/golang/xdb"
|
||||
)
|
||||
@ -23,6 +24,19 @@ const (
|
||||
BufferCache = 2
|
||||
)
|
||||
|
||||
func CachePolicyFromName(name string) (int, error) {
|
||||
switch strings.ToLower(name) {
|
||||
case "file", "nocache":
|
||||
return NoCache, nil
|
||||
case "vectorindex", "vindex", "vindexcache":
|
||||
return VIndexCache, nil
|
||||
case "content", "buffercache":
|
||||
return BufferCache, nil
|
||||
default:
|
||||
return NoCache, fmt.Errorf("invalid cache policy name `%s`", name)
|
||||
}
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
cachePolicy int
|
||||
ipVersion *xdb.Version
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user