bool scache_shadd(resource session, string path, mixed value)
bool $SCacheConnection->shadd(string path, mixed value)

scache_shadd is operationally equal to session spesific scache_add but unlike it, scache_shadd operates on shared storage that is common and accessible for all clients. Shared storage is for operating data common to all clients and for inter-client communication.

scache_shadd adds value to given path only if path does not contain previous value.

Functions scache_shset, scache_shadd and scache_shreplace are all for setting session values. Differencies are :


Session resource returned from scache_open, scache_reset or scache_connect
Slash (/) separated path on backend's session tree. Path parameter is not binary safe.
Value to be stored. Must be serialize()able.

Return values

TRUE on success, FALSE on failure.

In case of failure, error codes resolvable by scache_lasterr is one of below :



/* get connection */
$session = scache_reset('SharedCacheIsCommonForAllClients');

if (!scache_shexists($session, 'my/path') &&
     scache_shadd($session, 'my/path', 'value')) {

     echo "Mom! I inserted a value!\n";

if (!scache_shadd($session, 'my/path', 'another value')) {

    echo "It did not succeed any more..\n";