DB

platdb.DB
See theDB companion object
class DB(val path: String)(using ops: Options)

DB represents a database object consisting of several buckets, each of which is a collection of key-value pairs (nested buckets are supported). All operations performed by users on buckets are performed in transactions.

Attributes

Companion:
object
Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Concise view

Value members

Concrete methods

def backup(path: String): Try[Long]

Hot backup of the current database.

Hot backup of the current database.

Attributes

def begin(writable: Boolean): Try[Transaction]

Opens and returns a transactional object, or exception information if the opening fails. If the writable parameter is true, the method creates a read-write transaction, and if false, it creates a read-only transaction. Note that due to the transaction concurrency control mechanism, if a user wants to open a read-write transaction, the method blocks until the previous read-write transaction is closed.

Opens and returns a transactional object, or exception information if the opening fails. If the writable parameter is true, the method creates a read-write transaction, and if false, it creates a read-only transaction. Note that due to the transaction concurrency control mechanism, if a user wants to open a read-write transaction, the method blocks until the previous read-write transaction is closed.

Attributes

def close(): Try[Unit]

close database. this method will block until all opended transaction be commited or rollbacked.

close database. this method will block until all opended transaction be commited or rollbacked.

Attributes

def closed: Boolean

Attributes

def createCollection(name: String, collectionType: String, dimension: Int, ignoreExists: Boolean): Try[Unit]

Attributes

dimension

only when collectionType is Region,this paremeter worked.

ignoreExists

if this parameter is true,will ignore collecction object already exists error.

def delete(bucket: String, ignoreNotExists: Boolean, keys: Seq[String]): Try[Unit]

Attributes

def deleteCollection(name: String, collectionType: String, ignoreNotExists: Boolean): Try[Unit]

Attributes

def fillPercent: Double

Attributes

def get(bucket: String, key: String): Try[(String, String)]

Retrieves the element of the specified key from the specified bucket. returns a key-value pair if the element exists; If the element is a child bucket, an exception is returned.

Retrieves the element of the specified key from the specified bucket. returns a key-value pair if the element exists; If the element is a child bucket, an exception is returned.

Attributes

def get(bucket: String, keys: String*): Try[Seq[(String, String)]]

Retrieves multiple elements of the specified key from the specified bucket. Returns a key-value pair sequence if the element exists; If the element contains subbuckets, an exception is returned.

Retrieves multiple elements of the specified key from the specified bucket. Returns a key-value pair sequence if the element exists; If the element contains subbuckets, an exception is returned.

Attributes

def listCollection(collectionType: String): Try[Seq[(String, String)]]

query collections objects in current db.

query collections objects in current db.

Attributes

def name: String
def open(): Try[Unit]

The open method is used to open the DB, and if any exception is encountered, it will cause the opening to fail and return an error message. Currently, platdb does not support multiple processes opening the same DB at the same time, if a process wants to open a DB that is already held by another process, the opening process will be blocked until the holder closes the DB or throws a timeout exception.

The open method is used to open the DB, and if any exception is encountered, it will cause the opening to fail and return an error message. Currently, platdb does not support multiple processes opening the same DB at the same time, if a process wants to open a DB that is already held by another process, the opening process will be blocked until the holder closes the DB or throws a timeout exception.

Attributes

def pageSize: Int

Attributes

def put(bucket: String, key: String, value: String): Try[Unit]

Adds a key-value pair to the specified bucket, and its value is overwritten by the new value if the key already exists

Adds a key-value pair to the specified bucket, and its value is overwritten by the new value if the key already exists

Attributes

def put(bucket: String, elems: Seq[(String, String)]): Try[Unit]

Adds multiple key-value pairs to the specified bucket, and if some of the keys already exist, their values are overwritten by the new values.

Adds multiple key-value pairs to the specified bucket, and if some of the keys already exist, their values are overwritten by the new values.

Attributes

def readonly: Boolean

Attributes

def sync(): Try[Unit]
def tmpDir: String

Attributes

def tryBegin(writable: Boolean, timeout: Long): Future[Try[Transaction]]

This method is the same as the begin method, except that a timeout parameter is provided to prevent constant blocking when opening a read-write transaction.

This method is the same as the begin method, except that a timeout parameter is provided to prevent constant blocking when opening a read-write transaction.

Attributes

timeout

The unit is milliseconds

def update(op: Transaction => Unit): Try[Unit]

Executes user functions in the context of a read-write transaction. If the function does not produce any exceptions, the transaction is automatically committed; Otherwise, automatic rollback.

Executes user functions in the context of a read-write transaction. If the function does not produce any exceptions, the transaction is automatically committed; Otherwise, automatic rollback.

Attributes

def view(op: Transaction => Unit): Try[Unit]

Executes user functions in a read-only transaction context. If the function does not produce any exceptions, the transaction is automatically committed; Otherwise, automatic rollback. Performing a change database operation in a read-only transaction results in an exception.

Executes user functions in a read-only transaction context. If the function does not produce any exceptions, the transaction is automatically committed; Otherwise, automatic rollback. Performing a change database operation in a read-only transaction results in an exception.

Attributes

Concrete fields

val path: String