Advertisement
julong

test APC cache

Jan 5th, 2014
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. /* Test APC */
  2.  
  3. <?php
  4.  
  5. if($quote = apc_fetch('eakkasit')){
  6. echo $quote;
  7. echo "<br/>[cache]";
  8. }else{
  9. $quote = "Do , wor do not . There is no try. ";
  10. echo $quote;
  11. apc_add('eakkasit',$quote,2);
  12. }
  13. // if available, use cached data
  14. // if not, create and cache nested array
  15. echo "<br/>";
  16. if ($data = apc_fetch('config')) {
  17. echo 'Cached data: ';
  18. } else {
  19. $data = array(
  20. 'person1' => array(
  21. 'smtp' => array(
  22. 'host' => '192.168.0.1',
  23. 'user' => 'eakkasit',
  24. 'pass' => '1234'
  25. )
  26. ),
  27. 'person2' => array(
  28. 'smtp' => array(
  29. 'host' => '192.168.0.2',
  30. 'user' => 'poohkan',
  31. 'pass' => '4321'
  32. )
  33. ),
  34. );
  35. apc_add('config', $data, 120);
  36. }
  37.  
  38. // display data
  39. echo $data['person2']['smtp']['user'];
  40. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement