add to from string

This commit is contained in:
Bel LaPointe
2019-03-14 10:44:50 -06:00
parent b3a24aca42
commit 97b53aab90
4 changed files with 94 additions and 0 deletions

49
db.go
View File

@@ -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
}