Chat system example


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <?php
  2. /**
  3.  * Add a message to the chat
  4.  * @param Redis $redis Redis connection handler
  5.  * @param String $message message to add
  6.  * @return void
  7.  */
  8. function addMessage($redis, $message) {
  9. $redis->lPush("chat", $message);
  10. if($redis->lLen("chat") > 100) {
  11. $redis->rPop("chat");
  12. }
  13. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.