scache_shset

Description

bool scache_shset(resource session, string path, mixed value)
bool $SCacheConnection->shset(string path, mixed value)

scache_shset is operationally equal to session spesific scache_set but unlike it, scache_shset 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_shset sets value to given path on common all accessible shared storage. Previous value will be replaced. If previous value was subtree, subtree is destroyed.

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

Parameters

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

Return values

TRUE on success or FALSE on failure.

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

Examples

<?php

/* get connection */
$session = scache_shreset('ThisDoesNotMatterStorageIsShared');

* store and get */
if (scache_shset($session, 'my/values/path', 42) &&
    scache_shget($session, 'my/values/path') != 42) {

    /* unlikely to happen */
    die('scached is broken or someone got in middle');
}

scache_shset($session, 'this/path/was', 'subtree');
scache_shset($session, 'this/path/had', 'multiple values');
scache_shset($session, 'this/path/contained/also', 'subvalues');
scache_shset($session, 'this/path', 'got overwritten and subvalues deleted);
?>