add cache policy parse func
This commit is contained in:
parent
1b9fb0c95c
commit
b44654230f
|
|
@ -7,6 +7,7 @@ package service
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/lionsoul2014/ip2region/binding/golang/xdb"
|
"github.com/lionsoul2014/ip2region/binding/golang/xdb"
|
||||||
)
|
)
|
||||||
|
|
@ -23,6 +24,19 @@ const (
|
||||||
BufferCache = 2
|
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 {
|
type Config struct {
|
||||||
cachePolicy int
|
cachePolicy int
|
||||||
ipVersion *xdb.Version
|
ipVersion *xdb.Version
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue