forked from gyepisam/redux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnulldb.go
53 lines (42 loc) · 1.54 KB
/
nulldb.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Copyright 2014 Gyepi Sam. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package redux
// NullDb is a blackhole database, used for source files outside the redo project directory structure..
// It never fails, all writes disappear, and reads return nothing.
type NullDb struct {
}
// Open requires a project root argument
func NullDbOpen(ignored string) (DB, error) {
return &NullDb{}, nil
}
func (db *NullDb) IsNull() bool { return true }
// Put stores value under key
func (db *NullDb) Put(key string, value []byte) error {
return nil
}
// Get returns the value stored under key and a boolean indicating
// whether the returned value was actually found in the database.
func (db *NullDb) Get(key string) ([]byte, bool, error) {
return []byte{}, false, nil
}
// Delete removes the value stored under key.
// If key does not exist, the operation is a noop.
func (db *NullDb) Delete(key string) error {
return nil
}
// GetKeys returns a list of keys which have the specified key as a prefix.
func (db *NullDb) GetKeys(prefix string) ([]string, error) {
return []string{}, nil
}
// GetValues returns a list of values whose keys matching the specified key prefix.
func (db *NullDb) GetValues(prefix string) ([][]byte, error) {
return [][]byte{}, nil
}
// GetRecords returns a list of records (keys and data) matchign the specified key prefix.
func (db *NullDb) GetRecords(prefix string) ([]Record, error) {
return []Record{}, nil
}
func (db *NullDb) Close() error {
return nil
}