bool scache_rnrotf(resource session, string path, long count)
bool $SCacheConnection->rnrotf(string path, long count)

Rings have current position on what inserts and removes occur. Current position is regarded ring's first element and can be changed by rotating ring with scache_rnrotf and scache_rnrotb functions.

scache_rnrotf rotates ring forward in given path given count of steps. When rotating ring one step forward, current element becomes last element of ring.


Session resource returned from scache_open, scache_reset or scache_connect
Slash (/) separated null-terminated path on backend's session tree
Number of steps to rotate. Negative number rotates to oppisite direction

Return values

TRUE on success, FALSE on fail. On FALSE scache_lasterr returns last error code which is one of below :


Rotate functions allows negative stepping. Rotating one step forward equals rotating -1 steps backwards.


Enumeration through all elements on ring :

$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