scache_chput

Description

bool scache_chput(resource session, string path, mixed value)
bool $SCacheConnection->chput(string path, mixed value)

scache_chput stores values to shared cache. Values can be later fetch with scache_chget and removed by scache_chclear.

Please note that unlike other functions and all internal misnaming these functions really operate on cache. Scached backend is allowed to drop values in any time if memory limits are exceeded. Values are dropped by oldest accessed first. If you want to store values permanently, use scache_sh* functions that keep data until explicitly changed or removed.

Parameters

session
Session resource returned from scache_open, scache_reset or scache_connect
path
Slash (/) separated null-terminated path on backend's session tree
value
Value to be stored. Must be serialize()able.

Return values

TRUE on success, FALSE on fail. On FALSE scache_lasterr returns last error code which is one of below :

Examples

<?php

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

scache_chput($session, 'freely_droppable_value', 'for cache only');
if (scache_chget($session, 'freely_droppable_value')) {

    echo "Value found, but might also have been expired\n";
}
?>