scache_rnsize
Description
bool scache_rnsize(resource session, string path)
bool $SCacheConnection->rnsize(string path)
scache_rnsize returns size of ring in given path.
Parameters
session
path
Slash (/) separated null-terminated path on backend's session tree
Return values
TRUE on success, FALSE on fail. On FALSE scache_lasterr returns last error code which 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_LIMITS_REACHED Partition has exceeded its memory or node limits and new session cannot be created until memory is freed.
- 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.
Example
Enumeration through all elements on ring :
<?php $conn = scache_reset(md5(uniqid())); /* purge possible pre-existing */ scache_rnclear($conn, 'queue'); /* populate ring */ scache_rnpush($conn, 'queue', 1); // as first element scache_rnpush($conn, 'queue', 2); // as first element scache_rnpush($conn, 'queue', 3); // as first element for($i = 0, $count = scache_rnsize($conn, 'queue'); $i < $count; $i++) { echo "Pos $i: " . scache_rnget($conn, 'queue') . "\n"; scache_rnrotf($conn, 'queue', 1); } /* Displays Pos 0: 1 Pos 1: 2 Pos 2: 3 */ ?>