Citrusleaf PHP API

Class Citrusleaf

The Citrusleaf class contains all functionalities which can be used to access a Citrusleaf server.

Connecting

// connect to a specific citrusleaf cluster
public CitrusleafResult connect(string $citrusleaf_url)

Default Settings

// set/get default timeout for operations, in milliseconds
public CitrusleafResult set_default_timeout(int $millisecond)
public int get_default_timeout()

// set/get default write policy to use. 
public CitrusleafResult set_default_writepolicy(CitrusleafWritePolicy $policy)
public CitrusleafWritePolicy get_default_writepolicy()

// set/get default namespace to use
public CitrusleafResult set_default_namespace(string $namespace)
public string get_default_namespace()

// set/get default bin name
public CitrusleafResult set_default_bin(string $setname)
public string get_default_bin()

// set/get default set name
public CitrusleafResult set_default_set(string $setname)
public string get_default_set()

Writing/Reading

// gets all the bins for a particular row, or if an array of bin_names are supplied
// get only those bins 
// returns a CitrusleafReponse, which contains information such as CitrusleafResult
// generation of the data, and actual array of binname_value pairs
public CitrusleafResponse get(object $key, [array $bin_names])

// puts a row in a namespace, with the given binname-value array
// the $uniqueFlag specifies if a uniqueness constraint is desired
// the $current_generation value is used for optimistic lock versioning
// the $ttlseconds specifies when the row can be evicted
public CitrusleafResult put(object $key,array $single_bin_value,[WriteUniqueFlag uniqueFlag, int $current_generation,int $ttlseconds])

Miscellaneous

// for a bin that has numeric value, mathematically add the amount
public CitrusleafResult add(object $key,string $bin_name,int amount,[int $current_generation,int $ttlseconds])

// delete
public CitrusleafResult delete(object $key,[int $current_generation])

// connects to a particular node and gather information/statistics, using the requested well-known category_names 
public CitrusleafResult info(string $host,string $port,array $names)

Class CitrusleafResponse

The CitrusleafResponse object is returned in the "get" call, to encapsulate all information needed to be returned to the caller

// returns the actual result of the get call, whether it was successful
public CitrusleafResult get_response_code()
// returns the current generation (version) of this data 
public int get_generation()
// returns the binname_value array relevant to the call
public array get_bins()

Class CitrusleafResult

A CitrusleafResult is returned for each of the Citrusleaf calls. It indicates success or type of failure of the call.

class CitrusleafResult 
{
    const CITRUSLEAF_OK=0; 
    const CITRUSLEAF_NOT_SET=1;
    const CITRUSLEAF_SERVER_ERROR=2; 
    const CITRUSLEAF_CLIENT_ERROR=3; 
    const CITRUSLEAF_KEY_NOT_FOUND_ERROR=4; 
    const CITRUSLEAF_KEY_FOUND_ERROR=5; 
    const CITRUSLEAF_BIN_NOT_FOUND_ERROR=6; // only returned by a bin-specific "get"
    const CITRUSLEAF_BIN_FOUND_ERROR=7;
    const CITRUSLEAF_GENERATION_ERROR=8; 
    const CITRUSLEAF_PARAMETER_ERROR=9;
    const CITRUSLEAF_TIMEOUT=10;
    const CITRUSLEAF_NO_HOSTS=11;
    const CITRUSLEAF_INVALID_API_PARAM=12;
    const CITRUSLEAF_UNKNOWN=13;
};

Class CitrusleafWritePolicy

A CitrusleafWritePolicy specifies if any retry should automatically be done on "put" calls.

class CitrusleafWritePolicy
{
    const ONCE=1;
    const RETRY=2;
    const ASSURED=3;
};

Class CitrusleafWriteUniqueFlag

A CitrusleafWriteUniqueFlag Specifies if any uniqueness constraint should be applied on a "put" call.

class CitrusleafWriteUniqueFlag
{
    const NONE=0;
    const WRITE_ONLY_KEY_NOT_EXIST=1;
    const WRITE_ONLY_BINS_NOT_EXIST=2;
}