Differences are :
- scache_vadd adds value to counter in given path
- scache_vsub substracts value from counter in given path
- scache_vset replaces counter in path with given value
- scache_vunset removes counter from given path. Effectively scache_unset is equal to scache_vset($session, 0)
On success resulting value is returned, on failure return value is FALSE. Nonexisting values are considered as value zero.
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_NO_ACCESS Shared counters are 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.
Nonexistent value is considered as 0.
Note also that these are not session specific but common to all clients. Shared counters might be useful for mutual modifications tracking or incremental transient numbering.
<?php /* get connection */ $session = scache_reset('MyEasilyGuessableSecret'); scache_vset($session, 'my/unexistent/path', 10); echo scache_vsub($session, 'my/unexistent/path', 1); /* results : 9 */ ?>