aboutsummaryrefslogtreecommitdiff
path: root/src/dedo.go
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2025-02-06 18:37:59 -0300
committerEuAndreh <eu@euandre.org>2025-02-06 18:52:33 -0300
commitb6bccbea314a1432a213241046c42473d633735a (patch)
tree2f64d229bab25a3650919791c9e8aa63e34f8718 /src/dedo.go
parentsrc/dedo.go: Replace concrete *DB type with IDedo interface (diff)
downloaddedo-b6bccbea314a1432a213241046c42473d633735a.tar.gz
dedo-b6bccbea314a1432a213241046c42473d633735a.tar.xz
src/dedo.go: Start implementation of in-memory variation
Diffstat (limited to '')
-rw-r--r--src/dedo.go29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/dedo.go b/src/dedo.go
index 29cfb45..a6e951a 100644
--- a/src/dedo.go
+++ b/src/dedo.go
@@ -54,6 +54,7 @@ import (
"time"
"unsafe"
+ "pds"
g "gobang"
)
@@ -104,6 +105,14 @@ type elemRef struct {
index int
}
+type Value interface{
+ value() []byte // FIXME: should be - []byte | IBucket
+}
+
+type InMemory struct{
+ *pds.Map[[]byte, Value]
+}
+
type IDedo interface{
Close() error
View (func(tx *Tx) error) error
@@ -1624,6 +1633,26 @@ func initDB(db *DB, size int64) error {
return nil
}
+func OpenMemory() IDedo {
+ return &InMemory{pds.NewMap[[]byte, Value](nil)}
+}
+
+func (m *InMemory) Close() error {
+ return nil
+}
+
+func (m *InMemory) Path() string {
+ return ""
+}
+
+func (m *InMemory) Update(func(*Tx) error) error {
+ return nil
+}
+
+func (m *InMemory) View(func(*Tx) error) error {
+ return nil
+}
+
/// Open creates and opens a database at the given path. If the file does not
/// exist then it will be created automatically.
func OpenWith(path string, options OpenOptionsT) (IDedo, error) {