Add nonworking riak

This commit is contained in:
Bel LaPointe
2019-03-13 15:02:46 -06:00
parent 8a1cf7104c
commit 46e8c15573
5 changed files with 120 additions and 22 deletions

24
map.go
View File

@@ -6,15 +6,15 @@ import (
type Map map[string][]byte
func NewMap() Map {
func NewMap() *Map {
m := make(map[string][]byte)
n := Map(m)
return n
return &n
}
func (m Map) String() string {
func (m *Map) String() string {
s := ""
for k, v := range m {
for k, v := range *m {
if s != "" {
s += ",\n"
}
@@ -23,25 +23,25 @@ func (m Map) String() string {
return s
}
func (m Map) Close() error {
func (m *Map) Close() error {
m = nil
return nil
}
func (m Map) Get(key string) ([]byte, error) {
if _, ok := m[key]; !ok {
func (m *Map) Get(key string) ([]byte, error) {
if _, ok := (*m)[key]; !ok {
return nil, ErrNotFound
}
return m[key], nil
return (*m)[key], nil
}
func (m Map) Set(key string, value []byte) error {
func (m *Map) Set(key string, value []byte) error {
if value == nil {
if _, ok := m[key]; ok {
delete(m, key)
if _, ok := (*m)[key]; ok {
delete(*m, key)
}
return nil
}
m[key] = value
(*m)[key] = value
return nil
}