scache_stat
Description
long scache_stat(resource session, string path)
long $SCacheConnection->stat(string path)
scache_stat queries node given path and returns existence and type of it. Return value is :
- SCNODE_EMPTY Node has been removed. Must be considered as nonexisting value. scache_exists would return false.
- SCNODE_NONEXISTENT Node does not exist, scache_exists would return false.
- SCNODE_BRANCH Node contains subtree, ie. is path containing another subvalues. (Directory).
- SCNODE_VALUE Node contains value and is not subtree.
Parameters
session
path
Slash (/) separated path on backend's session tree. Path parameter is not binary safe.
Return values
Node type success, FALSE on failure. Node types are :
- SCNODE_NONEXISTENT Path does not exist.
- SCNODE_EMPTY Path has once existed, but has been cleared. Must be considered as not existing path ie same as nodetype SCNODE_NONEXISTENT.
- SCNODE_BRANCH Path queried is node containing subnodes ie. directory.
- SCNODE_VALUE Path queried is node containing value.
In case of failure, error codes resolvable by scache_lasterr is one of below :
- SCERR_NO_SESSION Connected session does not exist or has been expired. Connection is not valid any more.
- 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('MyEasilyGuessableSecret');
scache_set($session, 'this/is/my/path', 'value');
if (scache_stat($session, 'this/is/my/path') == SCNODE_VALUE)
echo "Yes, this is SCNODE_VALUE...\n";
if (scache_stat($session, 'this/is/my') == SCNODE_BRANCH)
echo "..and yes, you are right, this is SCNODE_BRANCH..\n";
?>
