showcache.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #!/usr/bin/env php
  2. <?php
  3. /*
  4. * StatusNet - the distributed open-source microblogging tool
  5. * Copyright (C) 2009, StatusNet, Inc.
  6. *
  7. * This program is free software: you can redistribute it and/or modify
  8. * it under the terms of the GNU Affero General Public License as published by
  9. * the Free Software Foundation, either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU Affero General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Affero General Public License
  18. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
  21. $shortoptions = "t:l:v:k:";
  22. $helptext = <<<ENDOFHELP
  23. USAGE: showcache.php <args>
  24. shows the cached object based on the args
  25. -t table Table to look up
  26. -l column Column to look up, default "id"
  27. -v value Value to look up
  28. -k key Key to look up; other args are ignored
  29. ENDOFHELP;
  30. require_once INSTALLDIR.'/scripts/commandline.inc';
  31. $karg = get_option_value('k');
  32. if (!empty($karg)) {
  33. $k = Cache::key($karg);
  34. } else {
  35. $table = get_option_value('t');
  36. if (empty($table)) {
  37. die("No table or key specified\n");
  38. }
  39. $column = get_option_value('l');
  40. if (empty($column)) {
  41. $column = 'id';
  42. }
  43. $value = get_option_value('v');
  44. $k = Memcached_DataObject::cacheKey($table, $column, $value);
  45. }
  46. print "Checking key '$k'...\n";
  47. $c = Cache::instance();
  48. if (empty($c)) {
  49. die("Can't initialize cache object!\n");
  50. }
  51. $obj = $c->get($k);
  52. if (empty($obj)) {
  53. print "Empty.\n";
  54. } else {
  55. var_dump($obj);
  56. print "\n";
  57. }