5.6.3.1. vlcp.service.kvdb.objectdb

Note

This document is generated from the source file.

View Source on GitHub

Created on 2016/3/24

author:hubo
class vlcp.service.kvdb.objectdb.ObjectDB(server)

Abstract transaction layer for KVDB

__init__(server)

Constructor

asynctransact(asyncupdater, withtime=False, maxretry=None, maxtime=60)

Read-Write transaction with asynchronous operations.

First, the asyncupdater is called with asyncupdater(last_info, container). last_info is the info from last AsyncTransactionLockException. When asyncupdater is called for the first time, last_info = None.

The async updater should be an async function, and return (updater, keys). The updater should be a valid updater function used in transaction API. keys will be the keys used in the transaction.

The async updater can return None to terminate the transaction without exception.

After the call, a transaction is automatically started with the return values of asyncupdater.

updater can raise AsyncTransactionLockException to restart the transaction from asyncupdater.

Parameters:
  • asyncupdater – An async updater asyncupdater(last_info, container) which returns (updater, keys)
  • withtime – Whether the returned updater need a timestamp
  • maxretry – Limit the max retried times
  • maxtime – Limit the execution time. The transaction is abandoned if still not completed after maxtime seconds.
asyncwritewalk(asyncwalker, withtime=False, maxtime=60)

A read-write transaction with walker factory

Parameters:
  • asyncwalker

    an async function called as asyncwalker(last_info, container) and returns (keys, walker), which are the same as parameters of writewalk

    param keys:initial keys used in walk
    param walker:A walker should be walker(walk, write), where walk is a function walk(key)->value to get a value from the database, and write is a function write(key, value) to save value to the database.

    A value can be write to a database any times. A walk called after write is guaranteed to retrieve the previously written value.

    raise AsyncTransactionLockException in walkers to restart the transaction

  • withtime – if withtime=True, an extra timestamp parameter is given to walkers, so walkers should be walker(key, value, walk, write, timestamp)
  • maxtime – max execution time of this transaction
get(key, requestid, nostale=False)

Get an object from specified key, and manage the object. Return a reference to the object or None if not exists.

getonce(key, nostale=False)

Get a object without manage it. Return a copy of the object, or None if not exists. Referenced objects are not retrieved.

gettimestamp()

Get a timestamp from database server

load(container)

Load module

mget(keys, requestid, nostale=False)

Get multiple objects and manage them. Return references to the objects.

mgetonce(keys, nostale=False)

Get multiple objects, return copies of them. Referenced objects are not retrieved.

munwatch(keys, requestid)

Cancel management of keys

mwatch(keys, requestid, nostale=False)

Try to return all the references, see watch()

transact(keys, updater, withtime=False, maxtime=60)

Try to update keys in a transact, with an updater(keys, values), which returns (updated_keys, updated_values).

The updater may be called more than once. If withtime = True, the updater should take three parameters: (keys, values, timestamp) with timestamp as the server time

unload(container, force=False)

Unload module

unwatch(key, requestid)

Cancel management of a key

unwatchall(requestid)

Cancel management for all keys that are managed by requestid

walk(keys, walkerdict, requestid, nostale=False)

Recursively retrieve keys with customized functions. walkerdict is a dictionary key->walker(key, obj, walk, save).

watch(key, requestid, nostale=False)

Try to find an object and return a reference. Use reference.isdeleted() to test whether the object exists. Use reference.wait(container) to wait for the object to be existed.

watchlist(requestid=None)

Return a dictionary whose keys are database keys, and values are lists of request ids. Optionally filtered by request id

writewalk(keys, walker, withtime=False, maxtime=60)

A read-write transaction with walkers

Parameters:
  • keys – initial keys used in walk. Provide keys already known to be necessary to optimize the transaction.
  • walker

    A walker should be walker(walk, write), where walk is a function walk(key)->value to get a value from the database, and write is a function write(key, value) to save value to the database.

    A value can be write to a database any times. A walk called after write is guaranteed to retrieve the previously written value.

  • withtime – if withtime=True, an extra timestamp parameter is given to walkers, so walker should be walker(walk, write, timestamp)
  • maxtime – max execution time of this transaction
class vlcp.service.kvdb.objectdb.RetrieveReply(*args, **kwargs)
class vlcp.service.kvdb.objectdb.RetrieveRequestSend(*args, **kwargs)