Documentation

Client
in package

Instantiate a Client instance to access an Aerospike database cluster and perform database operations.

The client is thread-safe. Only one client instance should be used per cluster. Multiple threads should share this cluster instance. Your application uses this class' API to perform database operations such as writing and reading records, and selecting sets of records. Write operations include specialized functionality such as append/prepend and arithmetic addition. Each record may have multiple bins, unless the Aerospike server nodes are configured as "single-bin". In "multi-bin" mode, partial records may be written or read by specifying the relevant subset of bins.

Table of Contents

Properties

$socket  : mixed

Methods

add()  : mixed
Add integer bin values to existing record bin values. The policy specifies the transaction timeout, record expiration and how the transaction is handled when the record already exists. This call only works for integer values.
append()  : mixed
Append bin string values to existing record bin values. The policy specifies the transaction timeout, record expiration and how the transaction is handled when the record already exists. This call only works for string values.
batch()  : array<string|int, mixed>
BatchExecute will read/write multiple records for specified batch keys in one batch call.
changePassword()  : mixed
ChangePassword changes a user's password. Clear-text password will be hashed using bcrypt before sending to server.
connect()  : mixed
Connects to the Aerospike database using the provided socket address.
createIndex()  : mixed
CreateIndex creates a secondary index.
createRole()  : mixed
CreateRole creates a user-defined role.
createUser()  : mixed
CreateUser creates a new user with password and roles. Clear-text password will be hashed using bcrypt before sending to server.
delete()  : bool
Delete record for specified key. The policy specifies the transaction timeout.
dropIndex()  : mixed
DropIndex deletes a secondary index. It will block until index is dropped on all nodes.
dropRole()  : mixed
DropRole removes a user-defined role.
dropUdf()  : mixed
DropUDF removes a package containing user defined functions in the server.
dropUser()  : mixed
DropUser removes a user from the cluster.
exists()  : bool
Determine if a record key exists. The policy can be used to specify timeouts.
get()  : Record
Read record for the specified key. Depending on the bins value provided, all record bins, only selected record bins or only the record headers will be returned. The policy can be used to specify timeouts.
getHeader()  : Record
Read record for the specified key. Depending on the bins value provided, all record bins, only selected record bins or only the record headers will be returned. The policy can be used to specify timeouts.
grantPrivileges()  : mixed
GrantPrivileges grant privileges to a user-defined role.
grantRoles()  : mixed
GrantRoles adds roles to user's list of roles.
listUdf()  : array<string|int, mixed>
ListUDF lists all packages containing user defined functions in the server.
prepend()  : mixed
Prepend bin string values to existing record bin values. The policy specifies the transaction timeout, record expiration and how the transaction is handled when the record already exists. This call only works for string values.
put()  : mixed
Write record bin(s). The policy specifies the transaction timeout, record expiration and how the transaction is handled when the record already exists.
query()  : Recordset
Execute a query on all server nodes and return a record iterator. The query executor puts records on a queue in separate threads. The calling thread concurrently pops records off the queue through the record iterator.
queryRoles()  : array<string|int, mixed>
QueryRole retrieves privileges for a given role.
queryUsers()  : array<string|int, mixed>
QueryUser retrieves roles for a given user.
registerUdf()  : mixed
RegisterUDF registers a package containing user defined functions with server.
revokePrivileges()  : mixed
RevokePrivileges revokes privileges from a user-defined role.
revokeRoles()  : mixed
RevokeRoles removes roles from user's list of roles.
scan()  : Recordset
Read all records in the specified namespace and set and return a record iterator. The scan executor puts records on a queue in separate threads. The calling thread concurrently pops records off the queue through the record iterator. Up to `policy.max_concurrent_nodes` nodes are scanned in parallel. If concurrent nodes is set to zero, the server nodes are read in series.
setAllowlist()  : mixed
SetAllowlist sets IP address whitelist for a role. If whitelist is nil or empty, it removes existing whitelist from role.
setQuotas()  : mixed
SetQuotas sets maximum reads/writes per second limits for a role. If a quota is zero, the limit is removed.
socket()  : string
Retrieves the socket address associated with this client.
touch()  : mixed
Reset record's time to expiration using the policy's expiration. Fail if the record does not exist.
truncate()  : mixed
Removes all records in the specified namespace/set efficiently.
udfExecute()  : mixed
Execute executes a user defined function on server and return results.

Properties

Methods

add()

Add integer bin values to existing record bin values. The policy specifies the transaction timeout, record expiration and how the transaction is handled when the record already exists. This call only works for integer values.

public add(WritePolicy $policy, Key $key, array<string|int, mixed> $bins) : mixed
Parameters
$policy : WritePolicy
$key : Key
$bins : array<string|int, mixed>

append()

Append bin string values to existing record bin values. The policy specifies the transaction timeout, record expiration and how the transaction is handled when the record already exists. This call only works for string values.

public append(WritePolicy $policy, Key $key, array<string|int, mixed> $bins) : mixed
Parameters
$policy : WritePolicy
$key : Key
$bins : array<string|int, mixed>

batch()

BatchExecute will read/write multiple records for specified batch keys in one batch call.

public batch(BatchPolicy $policy, array<string|int, mixed> $cmds) : array<string|int, mixed>

This method allows different namespaces/bins for each key in the batch. The returned records are located in the same list.

BatchRecord can be *BatchRead, *BatchWrite, *BatchDelete or *BatchUDF.

Requires server version 6.0+

Parameters
$policy : BatchPolicy
$cmds : array<string|int, mixed>
Return values
array<string|int, mixed>

changePassword()

ChangePassword changes a user's password. Clear-text password will be hashed using bcrypt before sending to server.

public changePassword(AdminPolicy $policy, string $user, string $password) : mixed
Parameters
$policy : AdminPolicy
$user : string
$password : string

connect()

Connects to the Aerospike database using the provided socket address.

public static connect(string $socket) : mixed

If a persisted client object is found for the given socket address, it is returned. Otherwise, a new client object is created, persisted, and returned.

Arguments

  • socket - A string representing the socket address of the Aerospike database.

Returns

  • Err("Error connecting to the database".into()) - If an error occurs during connection.
Parameters
$socket : string

createIndex()

CreateIndex creates a secondary index.

public createIndex(WritePolicy $policy, string $namespace, string $set_name, string $bin_name, string $index_name, IndexType $index_type, IndexCollectionType|null $cit, array<string|int, mixed>|null $ctx) : mixed

This asynchronous server call will return before the command is complete. The user can optionally wait for command completion by using the returned IndexTask instance. This method is only supported by Aerospike 3+ servers. If the policy is nil, the default relevant policy will be used.

Parameters
$policy : WritePolicy
$namespace : string
$set_name : string
$bin_name : string
$index_name : string
$index_type : IndexType
$cit : IndexCollectionType|null
$ctx : array<string|int, mixed>|null

createRole()

CreateRole creates a user-defined role.

public createRole(AdminPolicy $policy, string $role_name, array<string|int, mixed> $privileges, array<string|int, mixed> $allowlist, int $read_quota, int $write_quota) : mixed

Quotas require server security configuration "enable-quotas" to be set to true. Pass 0 for quota values for no limit.

Parameters
$policy : AdminPolicy
$role_name : string
$privileges : array<string|int, mixed>
$allowlist : array<string|int, mixed>
$read_quota : int
$write_quota : int

createUser()

CreateUser creates a new user with password and roles. Clear-text password will be hashed using bcrypt before sending to server.

public createUser(AdminPolicy $policy, string $user, string $password, array<string|int, mixed> $roles) : mixed
Parameters
$policy : AdminPolicy
$user : string
$password : string
$roles : array<string|int, mixed>

delete()

Delete record for specified key. The policy specifies the transaction timeout.

public delete(WritePolicy $policy, Key $key) : bool

The call returns true if the record existed on the server before deletion.

Parameters
$policy : WritePolicy
$key : Key
Return values
bool

dropIndex()

DropIndex deletes a secondary index. It will block until index is dropped on all nodes.

public dropIndex(WritePolicy $policy, string $namespace, string $set_name, string $index_name) : mixed

This method is only supported by Aerospike 3+ servers. If the policy is nil, the default relevant policy will be used.

Parameters
$policy : WritePolicy
$namespace : string
$set_name : string
$index_name : string

dropUdf()

DropUDF removes a package containing user defined functions in the server.

public dropUdf(WritePolicy $policy, string $package_name) : mixed

This asynchronous server call will return before command is complete. The user can optionally wait for command completion by using the returned RemoveTask instance.

This method is only supported by Aerospike 3+ servers. If the policy is nil, the default relevant policy will be used.

Parameters
$policy : WritePolicy
$package_name : string

get()

Read record for the specified key. Depending on the bins value provided, all record bins, only selected record bins or only the record headers will be returned. The policy can be used to specify timeouts.

public get(ReadPolicy $policy, Key $key, array<string|int, mixed>|null $bins) : Record
Parameters
$policy : ReadPolicy
$key : Key
$bins : array<string|int, mixed>|null
Return values
Record

getHeader()

Read record for the specified key. Depending on the bins value provided, all record bins, only selected record bins or only the record headers will be returned. The policy can be used to specify timeouts.

public getHeader(ReadPolicy $policy, Key $key) : Record
Parameters
$policy : ReadPolicy
$key : Key
Return values
Record

grantPrivileges()

GrantPrivileges grant privileges to a user-defined role.

public grantPrivileges(AdminPolicy $policy, string $role_name, array<string|int, mixed> $privileges) : mixed
Parameters
$policy : AdminPolicy
$role_name : string
$privileges : array<string|int, mixed>

grantRoles()

GrantRoles adds roles to user's list of roles.

public grantRoles(AdminPolicy $policy, string $user, array<string|int, mixed> $roles) : mixed
Parameters
$policy : AdminPolicy
$user : string
$roles : array<string|int, mixed>

listUdf()

ListUDF lists all packages containing user defined functions in the server.

public listUdf(ReadPolicy $policy) : array<string|int, mixed>

This method is only supported by Aerospike 3+ servers. If the policy is nil, the default relevant policy will be used.

Parameters
$policy : ReadPolicy
Return values
array<string|int, mixed>

prepend()

Prepend bin string values to existing record bin values. The policy specifies the transaction timeout, record expiration and how the transaction is handled when the record already exists. This call only works for string values.

public prepend(WritePolicy $policy, Key $key, array<string|int, mixed> $bins) : mixed
Parameters
$policy : WritePolicy
$key : Key
$bins : array<string|int, mixed>

put()

Write record bin(s). The policy specifies the transaction timeout, record expiration and how the transaction is handled when the record already exists.

public put(WritePolicy $policy, Key $key, array<string|int, mixed> $bins) : mixed
Parameters
$policy : WritePolicy
$key : Key
$bins : array<string|int, mixed>

query()

Execute a query on all server nodes and return a record iterator. The query executor puts records on a queue in separate threads. The calling thread concurrently pops records off the queue through the record iterator.

public query(QueryPolicy $policy, mixed $partition_filter, Statement $statement) : Recordset
Parameters
$policy : QueryPolicy
$partition_filter : mixed
$statement : Statement
Return values
Recordset

queryRoles()

QueryRole retrieves privileges for a given role.

public queryRoles(AdminPolicy $policy, string|null $role_name) : array<string|int, mixed>
Parameters
$policy : AdminPolicy
$role_name : string|null
Return values
array<string|int, mixed>

queryUsers()

QueryUser retrieves roles for a given user.

public queryUsers(AdminPolicy $policy, string|null $user) : array<string|int, mixed>
Parameters
$policy : AdminPolicy
$user : string|null
Return values
array<string|int, mixed>

registerUdf()

RegisterUDF registers a package containing user defined functions with server.

public registerUdf(WritePolicy $policy, string $udf_body, string $package_name, mixed $language) : mixed

This asynchronous server call will return before command is complete. The user can optionally wait for command completion by using the returned RegisterTask instance.

This method is only supported by Aerospike 3+ servers. If the policy is nil, the default relevant policy will be used.

Parameters
$policy : WritePolicy
$udf_body : string
$package_name : string
$language : mixed

revokePrivileges()

RevokePrivileges revokes privileges from a user-defined role.

public revokePrivileges(AdminPolicy $policy, string $role_name, array<string|int, mixed> $privileges) : mixed
Parameters
$policy : AdminPolicy
$role_name : string
$privileges : array<string|int, mixed>

revokeRoles()

RevokeRoles removes roles from user's list of roles.

public revokeRoles(AdminPolicy $policy, string $user, array<string|int, mixed> $roles) : mixed
Parameters
$policy : AdminPolicy
$user : string
$roles : array<string|int, mixed>

scan()

Read all records in the specified namespace and set and return a record iterator. The scan executor puts records on a queue in separate threads. The calling thread concurrently pops records off the queue through the record iterator. Up to `policy.max_concurrent_nodes` nodes are scanned in parallel. If concurrent nodes is set to zero, the server nodes are read in series.

public scan(ScanPolicy $policy, mixed $partition_filter, string $namespace, string $set_name, array<string|int, mixed>|null $bins) : Recordset
Parameters
$policy : ScanPolicy
$partition_filter : mixed
$namespace : string
$set_name : string
$bins : array<string|int, mixed>|null
Return values
Recordset

setAllowlist()

SetAllowlist sets IP address whitelist for a role. If whitelist is nil or empty, it removes existing whitelist from role.

public setAllowlist(AdminPolicy $policy, string $role_name, array<string|int, mixed> $allowlist) : mixed
Parameters
$policy : AdminPolicy
$role_name : string
$allowlist : array<string|int, mixed>

setQuotas()

SetQuotas sets maximum reads/writes per second limits for a role. If a quota is zero, the limit is removed.

public setQuotas(AdminPolicy $policy, string $role_name, int $read_quota, int $write_quota) : mixed

Quotas require server security configuration "enable-quotas" to be set to true. Pass 0 for quota values for no limit.

Parameters
$policy : AdminPolicy
$role_name : string
$read_quota : int
$write_quota : int

socket()

Retrieves the socket address associated with this client.

public socket() : string

Returns

A string representing the socket address.

Return values
string

truncate()

Removes all records in the specified namespace/set efficiently.

public truncate(InfoPolicy $policy, string $namespace, string $set_name, int|null $before_nanos) : mixed
Parameters
$policy : InfoPolicy
$namespace : string
$set_name : string
$before_nanos : int|null

udfExecute()

Execute executes a user defined function on server and return results.

public udfExecute(WritePolicy $policy, Key $key, string $package_name, string $function_name, array<string|int, mixed> $args) : mixed

The function operates on a single record. The package name is used to locate the udf file location:

udf file = /.lua

This method is only supported by Aerospike 3+ servers. If the policy is nil, the default relevant policy will be used.

Parameters
$policy : WritePolicy
$key : Key
$package_name : string
$function_name : string
$args : array<string|int, mixed>

        
On this page

Search results