Skip to content

Latest commit

 

History

History
74 lines (54 loc) · 3.79 KB

README.md

File metadata and controls

74 lines (54 loc) · 3.79 KB

Overview

The Aerospike PHP client API is described in the following sections:

User Defined Methods [to be implemented]

Admin Methods [to be implemented]

Implementation Status

So far the Runtime Configuration, Lifecycle and Connection Methods, Error Handling and Logging Methods, and parts of Key-Value Methods and Query and Scan Methods have been implemented.

The User Defined Methods and Admin Methods are yet to be implemented.

The Large Data Type Methods are to be determined (no spec available, yet).

We expect the specification of the PHP client to closely describe our next release, including the unimplemented methods. However, it is possible that some changes to the client spec will occur.

Persistent Connections

Initializing the C-client to connect to a specified cluster is a costly operation, so ideally the C-client should be reused for the multiple requests made against the same PHP process (as is the case for mod_php and fastCGI).

The PHP developer can determine whether the Aerospike class constructor will use persistent connections or not by way of an optional boolean argument. After the first time Aerospike::__construct() is called within the process, the extension will attempt to reuse the persistent connection.

When persistent connections are used the methods reconnect() and close() do not actually close the connection. Those methods only apply to instances of class Aerospike which use non-persistent connections.

Halting a Stream

Halting a query() or scan() result stream can be done by returning (an explicit) boolean false from the callback. The extension will capture the return value from the registered PHP callback, and pass it to the C-client. The C-client will then close the sockets to the nodes involved in streaming results, effectively halting it.

Handling Unsupported Types

See: as_bytes.h

  • Allow the user to configure their serializer through an option.
  • OPT_SERIALIZER : SERIALIZER_PHP (default), SERIALIZER_NONE, SERIALIZER_USER, (SERIALIZER_JSON)
  • when a write operation runs into types that do not map directly to Aerospike DB types it checks the OPT_SERIALIZER setting:
  • if SERIALIZER_NONE it returns an Aerospike::ERR_PARAM error
  • if SERIALIZER_PHP it calls the PHP serializer, sets the object's as_bytes_type to AS_BYTES_PHP
  • (if SERIALIZER_JSON it calls json_encode, sets the object's as_bytes_type AS_BYTES_JSON)
  • if SERIALIZER_USER it calls the PHP function the user registered a callback with Aerospike::setSerializer(), and sets as_bytes_type to AS_BYTES_BLOB
  • when a read operation extracts a value from an AS_BYTES type bin:
  • if it’s a AS_BYTES_PHP use the PHP unserialize function
  • (if it’s a AS_BYTES_JSON call json_decode)
  • if it’s a AS_BYTES_BLOB and the user registered a callback with Aerospike::setSerializer() call that function, otherwise place it in a PHP string

TBD

<?php

// Client interface to the Aerospike cluster.
class Aerospike
{
    // Large Data Type (LDT) APIs:
    public function getLargeList($key_z);
    public function getLargeMap($key_z);
    public function getLargeSet($key_z);
    public function getLargeStack($key_z);

    // helper method for combining predicates, such as predicate1 AND predicate2
    // when server implementation arrives
    public array Aerospike::conjoin ( array $predicate, string $conjunction, array $next_predicate [, boolean $parenthesize = false] )
}
?>