Advertisement
livechatinc

SaveStatusToMemcache

Sep 30th, 2015
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.45 KB | None | 0 0
  1. <?php
  2.  
  3. $cacheAge=60;
  4. $memcache = new Memcache();
  5.  
  6. $result = $_memcache->get('livechat_status');
  7.  
  8. if (!$result)
  9. {
  10.    try {
  11.    $API = new LiveChat_API();
  12.    $status = $API->status->get();
  13.    $_memcache = new Memcache;
  14.    $_memcache->connect('127.0.0.1', 11211);
  15.    $_memcache->set('livechat_status', $status, false, $cacheAge);
  16.    return $status;
  17.    }
  18.    catch (Exception $e) {
  19.    die($e->getCode().' '.$e->getMessage());
  20.    }
  21. }
  22. return result;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement