Memcache-based Queue PHP code written in PHP
0) {self: mqFrontChange ($ num);} return self: $ m_data;} private static function mqRealChange () {memcache_add (self: $ client, self :: QUEUE_REAL_KEY, 0); self: $ m_real = memcache_increment (self: $ client, self: QUEUE_REAL_KEY, 1);} private static function mqFrontChange ($ num) {memcache_add (self ::$ client, self: QUEUE_FRONT_KEY, 0); self ::$ m_front = memcache_increment (self ::$ client, self: QUEUE_FRONT_KEY, $ num);} public static function mflush ($ memcache_obj) {memcache_flush ($ memcache_obj);} public static function Debug () {echo 'real :'. self: $ m_real."
/R/n "; echo 'front: '. self: $ m_front ."
/R/n "; echo 'wait for process data: '. intval (self ::$ m_real-self ::$ m_front); echo"
/R/n "; echo''; Print_r (self: $ m_data); echo''; } } define('FLUSH_MQ',0);//CLEAN ALL DATA define('IS_ADD',0);//SET DATA $mobj = MQ::setupMq('127.0.0.1','11211'); if (FLUSH_MQ) { MQ::mflush($mobj); } else { if (IS_ADD) { MQ::add('user_sync', '1test'); MQ::add('user_sync', '2test'); MQ::add('user_sync', '3test'); MQ::add('user_sync', '4test'); MQ::add('user_sync', '5test'); MQ::add('user_sync', '6test'); } else { MQ::get('user_sync', 10); } } MQ::Debug(); ?>Usage
MQ: setupMq ('2017. 0.0.1 ', '000000'); // Connect MQ: add ($ key, $ value); // add data to the queue MQ: add ($ key, $ value); // add data to the queue MQ: add ($ key, $ value); // add data to the queue MQ: add ($ key, $ value ); // add data to the queue MQ: add ($ key, $ value); // add data to the queue MQ: add ($ key, $ value ); // add data to the MQ queue: get ($ key, 10); // Retrieve a certain amount of data