scache_set

Description

bool scache_set(resource session, string path, mixed value)
bool $SCacheConnection->set(string path, mixed value)

scache_set sets value to given path on session-private storage. Previous value will be replaced. If previous value was subtree, subtree is destroyed.

Functions scache_set, scache_add and scache_replace 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, FALSE on failure.

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

Examples

<?php

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

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

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

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