Quasardb API for PHP
Introduction Installation Compilation Configuration API Reference

Namespaces

  • qdb

Classes

  • qdb\QdbAliasAlreadyExistsException
  • qdb\QdbAliasNotFoundException
  • qdb\QdbBatch
  • qdb\QdbBatchResult
  • qdb\QdbBlob
  • qdb\QdbCluster
  • qdb\QdbConnectionException
  • qdb\QdbContainerEmptyException
  • qdb\QdbDeque
  • qdb\QdbEntry
  • qdb\QdbEntryCollection
  • qdb\QdbException
  • qdb\QdbExpirableEntry
  • qdb\QdbIncompatibleTypeException
  • qdb\QdbInputException
  • qdb\QdbInteger
  • qdb\QdbOperationDisabledException
  • qdb\QdbOperationException
  • qdb\QdbProtocolException
  • qdb\QdbSystemException
  • qdb\QdbTag
  • qdb\QdbTagCollection
  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:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 
<?php
namespace qdb;
/**
 * A blob in the database.
 *
 * Blob stands for Binary Large Object, meaning that you can store arbitrary data in this blob.
 * @example
 * You get a `QdbBlob` instance by calling {@link \QdbCluster::blob}.
 * Then you can perform atomic operations on the blob:
 * <code>
 * $cluster->blob('key 0')->put('value 0');
 * $cluster->blob('key 1')->put('value 1');
 * $value2 = $cluster->blob('key 2')->get();
 * </code>
 */
class QdbBlob extends QdbExpirableEntry
{
    /**
     * Atomically compares the blob's content with `$comparand` and updates it to `$new_content` if, and only if, they match.
     *
     * @example
     * <code>
     * $oldContent = $cluster->blob('alias')->compareAndSwap('newContent', 'comparand');
     * </code>
     *
     * @param string $new_content The new content of the blob in case of a match.
     * @param string $comparand The content to be compared to.
     * @param int $expiry_time The absolute expiration time, in seconds since epoch (`0` means "never expires").
     * @return string The original content of the blob if it didn't match `$comparand`; `null` if it matched.
     * @throws QdbAliasNotFoundException
     * @throws QdbIncompatibleTypeException
     */
    function compareAndSwap($new_content, $comparand, $expiry_time);

    /**
     * Reads the blob's content.
     *
     * @example
     * <code>
     * $content = $cluster->blob('alias')->get();
     * </code>
     *
     * @return string The blob's content.
     * @throws QdbAliasNotFoundException
     * @throws QdbIncompatibleTypeException
     */
    function get();

    /**
     * Atomically gets blob's content and removes it.
     *
     * @example
     * <code>
     * $content = $cluster->blob('alias')->getAndRemove();
     * </code>
     *
     * @return string The blob's content.
     * @throws QdbAliasNotFoundException
     * @throws QdbIncompatibleTypeException
     */
    function getAndRemove();

    /**
     * Atomically gets the blob's content and replaces it.
     *
     * @example
     * <code>
     * $oldContent = $cluster->blob('alias')->getAndUpdate('newContent');
     * </code>
     *
     * @param string $content The new content of the blob.
     * @param int $expiry_time The absolute expiration time, in seconds since epoch (`0` means "never expires").
     * @return string The blob's content.
     * @throws QdbAliasNotFoundException
     * @throws QdbIncompatibleTypeException
     */
    function getAndUpdate($content, $expiry_time=0);

    /**
     * Sets the blob's content, fails if it already exists.
     *
     * @example
     * <code>
     * $cluster->blob('alias')->put('content');
     * </code>
     *
     * @param string $content The initial content of the blob.
     * @param int $expiry_time The absolute expiration time, in seconds since epoch (`0` means "never expires").
     * @throws QdbAliasAlreadyExistsException
     * @throws QdbIncompatibleTypeException
     */
    function put($content, $expiry_time=0);

    /**
     * Removes the blob if content matches.
     *
     * @example
     * <code>
     * $removed = $cluster->blob('alias')->removeIf('comparand');
     * </code>
     *
     * @param string $comparand The content to be compared to.
     * @return bool `true` if the blob was actually removed; `false` if not.
     * @throws QdbAliasNotFoundException
     * @throws QdbIncompatibleTypeException
     */
    function removeIf();

    /**
     * Sets the blob's content, creates the blob if needed.
     *
     * @example
     * <code>
     * $cluster->blob('alias')->update('content');
     * </code>
     *
     * @param string $content The new content of the blob.
     * @param int $expiry_time The absolute expiration time, in seconds since epoch (`0` means "never expires").
     * @return bool `true` if the integer was created; `false` if it was updated.
     * @throws QdbIncompatibleTypeException
     */
    function update($content, $expiry_time);
}
?>
Copyright 2009-2018 quasardb SAS Documentation generated by ApiGen