Exemple #1
0
 /**
  * 
  * @param string $key
  * @param callable $callable
  * @param integer $expiration
  * @return array
  */
 protected function cacheGet($key, $callable, $expiration = 900)
 {
     $cacheKey = 'statistics/' . $this->lang . '/' . $key;
     $cache = MongoCache::getInstance();
     $result = $cache->get($cacheKey);
     if ($result) {
         return $result;
     }
     $result = $callable();
     $cache->set($cacheKey, $result, $expiration);
     return $result;
 }
Exemple #2
0
 /**
  * 
  * @return array
  */
 public function getSkinItems($skin_ids)
 {
     if (empty($skin_ids)) {
         return [];
     }
     $cache = MongoCache::getInstance();
     $lang = Translator::getInstance()->getLang();
     $collection = $cache->getCache()->getMongoCollection($lang . '_items');
     $objects = [];
     foreach ($collection->find(['value.default_skin' => ['$in' => $skin_ids]]) as $doc) {
         if (!isset($objects[$doc['value']['default_skin']])) {
             $objects[$doc['value']['default_skin']] = $doc['value']['id'];
         }
     }
     $client = self::getInstance($lang);
     $client->v2_items(array_values($objects));
     foreach ($objects as $skin_id => $item_id) {
         $objects[$skin_id] = new Item($client, $item_id);
     }
     return $objects;
 }