Guest User

Untitled

a guest
May 24th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. <?php
  2. function register_action($action) {
  3. error_log(microtime(true) . "\n", 3, "/tmp/tagmy.$action");
  4. }
  5.  
  6. function log_info($msg) {
  7. error_log(date("Y-m-d H:i:s") . " $msg\n", 3, "/tmp/tagmy.log.info");
  8. }
  9.  
  10. function try_from_cache() {
  11. global $memcache;
  12.  
  13. if ($memcache) {
  14. $img = $memcache->get(file_name());
  15. if ($img) {
  16. log_info('memcache hit for ' . file_name() . ' ' . $_SERVER["REQUEST_URI"]);
  17. register_action("image.cached");
  18. send_headers();
  19. echo $img;
  20. exit();
  21. } else {
  22. log_info('memcache miss for ' . file_name() . ' ' . $_SERVER["REQUEST_URI"]);
  23. }
  24. }
  25. }
  26.  
  27. function do_image() {
  28. global $UriParts;
  29.  
  30. try_from_cache();
  31.  
  32. ... lots of work to make the image ...
  33.  
  34. register_action("image.created");
  35. }
Add Comment
Please, Sign In to add comment