scache_chclear
Description
bool scache_chclear(resource session, string path)
bool $SCacheConnection->chclear(string path)
scache_chclear removes values from shared cache.
Parameters
session
path
Slash (/) separated null-terminated path on backend's session tree
Return values
TRUE on success. FALSE on failure. If node was already empty or nonexisting one, TRUE is returned, but error code is set to SCERR_NOTEXIST.
In case of failure, error codes resolvable by scache_lasterr is one of below :
- SCERR_NOTEXIST Path given does not exist.
- 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.
Notes
When caching data it might be useful to organize them as subtrees by dependency so that they can be expired as entity (complete subtree) when something dependent to them all gets invalidated.
Example
<?php /* get connection */ $session = scache_reset('CacheIsSharedFunction_NotSessionSpecific'); /* we cache gradually more and more values */ scache_chput($session, 'freely/droppable/value1', 'for cache only'); scache_chput($session, 'freely/droppable/value2', 'for cache only'); scache_chput($session, 'freely/accessible/data', 'is here'); scache_chput($session, 'freely/exportable/data', 'is here'); scache_chput($session, 'another/data', 'is also available'); scache_chput($session, 'this/is/quite', 'permanent'); /* 'freely' object got modified in database so we expire all dependent cached values in one turn by expiring parent key */ scache_chclear($session, 'freely'); ?>