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
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 :
- SCERR_NO_SESSION Connected session does not exist or has been expired. Connection is not valid any more.
- SCERR_NO_ACCESS Caching is not allowed on assigned partition.
- SCERR_NOT_CONNECTED Connection to backend is broken and cannot be reconnected.
- SCERR_PROTOCOL Internal protocol error has occurred when communicating to backend. This indicates something is severely broken.
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"; } ?>