Cache.php 644 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. namespace controllers;
  3. use controllers\utils\DbTrait;
  4. /**
  5. * Bench controller.
  6. */
  7. class Cache extends \Ubiquity\controllers\Controller {
  8. protected $cache;
  9. public function __construct() {
  10. $this->cache = \Ubiquity\orm\DAO::getCache();
  11. }
  12. public function initialize() {
  13. \Ubiquity\utils\http\UResponse::setContentType('application/json');
  14. }
  15. public function index() {}
  16. public function cachedquery($queries = 1) {
  17. $worlds = [];
  18. $count = \min(\max((int) $queries, 1), 500);
  19. while ($count --) {
  20. $worlds[] = ($this->cache->fetch('models\\CachedWorld', \mt_rand(1, 10000)))->_rest;
  21. }
  22. echo \json_encode($worlds);
  23. }
  24. }