add to from string
This commit is contained in:
49
db.go
49
db.go
@@ -1,5 +1,7 @@
|
||||
package storage
|
||||
|
||||
import "strings"
|
||||
|
||||
type DB interface {
|
||||
Get(string) ([]byte, error)
|
||||
Set(string, []byte) error
|
||||
@@ -7,3 +9,50 @@ type DB interface {
|
||||
}
|
||||
|
||||
var DefaultNamespace = "namespace"
|
||||
|
||||
type Type int
|
||||
|
||||
const (
|
||||
MAP = Type(iota)
|
||||
BOLT = Type(iota)
|
||||
CACHE = Type(iota)
|
||||
LEVELDB = Type(iota)
|
||||
MEMCACHE = Type(iota)
|
||||
MEMCACHECLUSTER = Type(iota)
|
||||
MONGO = Type(iota)
|
||||
)
|
||||
|
||||
func (t Type) String() string {
|
||||
switch t {
|
||||
case MAP:
|
||||
return "map"
|
||||
case BOLT:
|
||||
return "bolt"
|
||||
case CACHE:
|
||||
return "cache"
|
||||
case LEVELDB:
|
||||
return "leveldb"
|
||||
case MEMCACHE:
|
||||
return "memcache"
|
||||
case MEMCACHECLUSTER:
|
||||
return "memcachecluster"
|
||||
case MONGO:
|
||||
return "mongo"
|
||||
}
|
||||
return "<unknown>"
|
||||
}
|
||||
|
||||
func TypeFromString(key string) Type {
|
||||
key = strings.ToLower(key)
|
||||
for i := 0; i < 30; i++ {
|
||||
t := Type(i)
|
||||
if t.String() == key {
|
||||
return t
|
||||
}
|
||||
}
|
||||
return Type(-1)
|
||||
}
|
||||
|
||||
func New(key Type) (DB, error) {
|
||||
return nil, ErrNotImpl
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user