mirror of
https://github.com/logos-storage/nim-datastore.git
synced 2026-01-06 23:53:09 +00:00
reorg
This commit is contained in:
parent
01ccbb5798
commit
82bf1f1a3c
@ -19,55 +19,55 @@ push: {.upraises: [].}
|
||||
|
||||
|
||||
type
|
||||
SQLiteDatastore* = ref object of Datastore
|
||||
FSDatastore* = ref object of Datastore
|
||||
db: ThreadDatastore[SQLiteBackend[KeyId, DataBuffer]]
|
||||
|
||||
proc path*(self: SQLiteDatastore): string =
|
||||
proc path*(self: FSDatastore): string =
|
||||
self.db.backend.path()
|
||||
|
||||
proc readOnly*(self: SQLiteDatastore): bool =
|
||||
proc readOnly*(self: FSDatastore): bool =
|
||||
self.db.backend.readOnly()
|
||||
|
||||
method has*(self: SQLiteDatastore,
|
||||
method has*(self: FSDatastore,
|
||||
key: Key): Future[?!bool] {.async.} =
|
||||
await self.db.has(key)
|
||||
|
||||
method delete*(self: SQLiteDatastore,
|
||||
method delete*(self: FSDatastore,
|
||||
key: Key): Future[?!void] {.async.} =
|
||||
await self.db.delete(key)
|
||||
|
||||
method delete*(self: SQLiteDatastore,
|
||||
method delete*(self: FSDatastore,
|
||||
keys: seq[Key]): Future[?!void] {.async.} =
|
||||
await self.db.delete(keys)
|
||||
|
||||
method get*(self: SQLiteDatastore,
|
||||
method get*(self: FSDatastore,
|
||||
key: Key): Future[?!seq[byte]] {.async.} =
|
||||
await self.db.get(key)
|
||||
|
||||
method put*(self: SQLiteDatastore,
|
||||
method put*(self: FSDatastore,
|
||||
key: Key,
|
||||
data: seq[byte]): Future[?!void] {.async.} =
|
||||
await self.db.put(key, data)
|
||||
|
||||
method put*(self: SQLiteDatastore,
|
||||
method put*(self: FSDatastore,
|
||||
batch: seq[BatchEntry]): Future[?!void] {.async.} =
|
||||
await self.db.put(batch)
|
||||
|
||||
method close*(self: SQLiteDatastore): Future[?!void] {.async.} =
|
||||
method close*(self: FSDatastore): Future[?!void] {.async.} =
|
||||
await self.db.close()
|
||||
|
||||
method query*(self: SQLiteDatastore,
|
||||
method query*(self: FSDatastore,
|
||||
q: Query): Future[?!QueryIter] {.async.} =
|
||||
await self.db.query(q)
|
||||
|
||||
proc new*(
|
||||
T: type SQLiteDatastore,
|
||||
T: type FSDatastore,
|
||||
path: string,
|
||||
readOnly = false,
|
||||
tp: Taskpool,
|
||||
): ?!SQLiteDatastore =
|
||||
): ?!FSDatastore =
|
||||
|
||||
let
|
||||
backend = ? newSQLiteBackend[KeyId, DataBuffer](path, readOnly)
|
||||
db = ? ThreadDatastore.new(backend, tp = tp)
|
||||
success SQLiteDatastore(db: db)
|
||||
success FSDatastore(db: db)
|
||||
|
||||
@ -60,14 +60,10 @@ for i in 1..N:
|
||||
suite "Test Query ThreadDatastore with SQLite " & $i:
|
||||
|
||||
var
|
||||
sqlStore: SQLiteBackend[KeyId, DataBuffer]
|
||||
# taskPool: Taskpool
|
||||
ds: ThreadDatastore[SQLiteBackend[KeyId, DataBuffer]]
|
||||
ds: SQLiteDatastore
|
||||
|
||||
setup:
|
||||
sqlStore = newSQLiteBackend[KeyId, DataBuffer](Memory).tryGet()
|
||||
# taskPool = Taskpool.new(NumThreads)
|
||||
ds = ThreadDatastore.new(sqlStore, tp = taskPool).tryGet()
|
||||
ds = SQLiteDatastore.new(Memory, tp = taskPool).tryGet()
|
||||
|
||||
teardown:
|
||||
GC_fullCollect()
|
||||
@ -88,8 +84,7 @@ suite "Test Basic ThreadDatastore with fsds":
|
||||
otherBytes = "some other bytes".toBytes
|
||||
|
||||
var
|
||||
fsStore: FSDatastore[KeyId, DataBuffer]
|
||||
ds: ThreadDatastore[FSDatastore[KeyId, DataBuffer]]
|
||||
ds: SQLiteDatastore
|
||||
|
||||
setupAll:
|
||||
removeDir(basePathAbs)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user