scache_vset
Description
long scache_vset(resource session, string path, int value)
long $SCacheConnection->vset(string path, long value)
scache_vadd, scache_vsub, scache_vset, scache_vunset operate shared counters on scached backend.
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)
Parameters
session
path
Slash (/) separated null-terminated path on backend's session tree
value
Value to add.
Return values
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.
Notes
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.
Examples
<?php /* get connection */ $session = scache_reset('MyEasilyGuessableSecret'); scache_vset($session, 'my/unexistent/path', 2); ?>