bool scache_rnpop(resource session, string path)
bool $SCacheConnection->rnpop(string path)

scache_rnpop retrieves last element from end of a ring in given path. First (ie. current) element can be retrieved with scache_rnshift.

Both scache_rnpop and scache_rnshift remove element from ring after retrieving while scache_rnget doesn't remove element it touches.


Session resource returned from scache_open, scache_reset or scache_connect
Slash (/) separated null-terminated path on backend's session tree

Return values

Stored content on success or FALSE if given path does not exist or error occurred.

In case of failure, error codes resolvable by scache_lasterr is one of below :


scache_rnpush, scache_rnunshift, scache_rnpop and scache_rnshift are generally useful from implementing work queues.


$conn = scache_reset(md5(uniqid()));

/* purge possible pre-existing */
scache_rnclear($conn, 'queue');

/* FIFO -purging */
scache_rnpush($conn, 'queue', 1); // as first element
scache_rnpush($conn, 'queue', 2); // as first element
scache_rnpush($conn, 'queue', 3); // as first element

scache_rnsize($conn, 'queue');  // returns 3
scache_rnshift($conn, 'queue'); // returns 1     
scache_rnsize($conn, 'queue');  // returns 2             
scache_rnshift($conn, 'queue'); // returns 2     
scache_rnsize($conn, 'queue');  // returns 1