当前位置: 首页>>代码示例>>PHP>>正文


PHP cache::Memcached方法代码示例

本文整理汇总了PHP中cache::Memcached方法的典型用法代码示例。如果您正苦于以下问题:PHP cache::Memcached方法的具体用法?PHP cache::Memcached怎么用?PHP cache::Memcached使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cache的用法示例。


在下文中一共展示了cache::Memcached方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: prepare

 public function prepare()
 {
     global $settings;
     $this->template = "players";
     $this->tab = "player";
     $this->title = "Player search";
     if ($this->request['search']) {
         // Split out URLs! :x
         $str = trim($this->request['search']);
         $str_array = explode('/', $str);
         $sbit = $str_array[count($str_array) - 1];
         if (!$sbit) {
             $sbit = $str_array[count($str_array) - 2];
         }
         header('Location: /player/' . $sbit);
     } else {
         @(include 'cache/valve_employees.php');
         global $VALVE_EMPLOYEES;
         $views = cache::Memcached()->get('player_views');
         if ($views === false) {
             $json = file_get_contents($settings['cache']['folder'] . 'player_views.json');
             $views = json_decode($json, true);
             cache::Memcached()->set('player_views', $views, time() + 60 * 15);
         }
         $this->params['views'] = $views;
         $this->params['valve_employees'] = $VALVE_EMPLOYEES;
     }
 }
开发者ID:mwilchez,项目名称:master,代码行数:28,代码来源:players.view.php

示例2: prepare

 public function prepare()
 {
     global $db, $settings;
     $this->template = "servers";
     $this->tab = 'server';
     $this->title = "Server search";
     $server_stats = cache::Memcached()->get('server_stats');
     if ($server_stats === false) {
         $json = file_get_contents($settings['cache']['folder'] . 'server_stats.json');
         $server_stats = json_decode($json, true);
         cache::Memcached()->set('server_stats', $server_stats, time() + 60 * 15);
     }
     $this->params['stats'] = $server_stats;
 }
开发者ID:mwilchez,项目名称:master,代码行数:14,代码来源:servers.view.php

示例3: prepare

 public function prepare()
 {
     global $schema, $settings;
     $this->template = "paints";
     $this->tab = 'item';
     $this->title = "Paint statistics";
     $sort_table = array('total' => 'painted', 'owned' => 'owned', 'used' => 'usage');
     $b = new backpack(false);
     $sortkey = 'painted';
     if ($this->request['sort'] && array_key_exists($this->request['sort'], $sort_table)) {
         $sortkey = $sort_table[$this->request['sort']];
         $this->params['sort'][$this->request['sort']] = 'selected';
     } else {
         $this->params['sort']['total'] = 'selected';
     }
     $item_stats = cache::Memcached()->get('item_stats');
     if ($item_stats === false) {
         $json = file_get_contents($settings['cache']['folder'] . 'item_stats.json');
         $item_stats = json_decode($json, true);
         cache::Memcached()->set('item_stats', $item_stats, time() + 60 * 15);
     }
     $total_paints = $item_stats['total_colors'];
     $total_items = $item_stats['total_items'];
     foreach ($item_stats['colors'] as $c => $p) {
         $id = get_paint_by_color($c);
         if (!$id) {
             continue;
         }
         //printf("Color: %s, id: %s <br />",$c, $id);
         $s = $item_stats['items'][$id];
         $si = $schema['items'][$id];
         $i = $b->get_item($si);
         $owned = $s['total'] / $item_stats['total_players'];
         //printf("Owned: %s, Total: %s<br>", $s['total'], $item_stats['total_players']);
         $paint = array('total' => $p, 'color' => $c, 'painted' => $p / $total_paints, 'owned' => ($s['total'] + $p) / $item_stats['total_players'], 'usage' => $p / ($s['total'] + $p));
         $key = (string) intval($paint[$sortkey] * 10000);
         while ($paints[$key] > 0) {
             $key++;
         }
         //printf("%s -> %s: %s<br />",$paint[$sortkey], $key, $i['name']);
         $paints[$key] = array_merge($paint, $i);
     }
     $this->params['paints'] = $paints;
     krsort($this->params['paints']);
     $this->params['profiles'] = $item_stats['total_players'];
     $this->params['time'] = cache::date('item_stats.json');
 }
开发者ID:mwilchez,项目名称:master,代码行数:47,代码来源:paints.view.php

示例4: prepare

 public function prepare()
 {
     global $schema, $settings;
     $this->template = "effects";
     $this->tab = 'item';
     $this->title = "Effect statistics";
     $b = new backpack(false);
     $item_stats = cache::Memcached()->get('item_stats');
     if ($item_stats === false) {
         $json = file_get_contents($settings['cache']['folder'] . 'item_stats.json');
         $item_stats = json_decode($json, true);
         cache::Memcached()->set('item_stats', $item_stats, time() + 60 * 15);
     }
     $total_effects = $item_stats['total_effects'];
     $total_items = $item_stats['total_items'];
     foreach ($item_stats['effects'] as $c => $p) {
         $c = (int) $c;
         // I don't even
         //if($c && $c > 0)
         //{
         $name = int_to_effect($c);
         $class = 'rarity4';
         if ($c == 4) {
             $class = 'community';
         }
         if ($c == 2) {
             $class = 'developer';
         }
         $img = sprintf("%sxy78/%d.png", $settings['upload']['resized_ext']['effects'], $c);
         if (!file_exists($settings['upload']['folder']['effects'] . $c . '.png')) {
             $img = '/static/images/items/sized/xy78/unknown.png';
         }
         $i = $p;
         while ($effects[(string) $i]) {
             $i += 0.01;
         }
         $effects[(string) $i] = array('total' => $p / $total_effects, 'global' => $p / $total_items, 'players' => $p / $item_stats['total_players'], 'effect' => $c, 'image' => $img, 'name' => $name, 'tooltip' => sprintf('<h1 class="%s">%s</h1>', $class, $name), 'raw' => $p, 'sort' => $i);
         //}
     }
     $this->params['effects'] = $effects;
     krsort($this->params['effects']);
     $this->params['profiles'] = $item_stats['total_players'];
     $this->params['time'] = cache::date('item_stats.json');
 }
开发者ID:mwilchez,项目名称:master,代码行数:44,代码来源:effects.view.php

示例5: prepare

 public function prepare()
 {
     global $schema, $base_weapons, $slot_order, $settings;
     $this->template = "weapons";
     $this->tab = 'item';
     $this->title = 'Weapon statistics';
     $this->canonical = 'http://tf2stats.net/weapons/';
     $sort_table = array('owned' => 'owned', 'equipped' => 'equipped', 'own_equip' => 'owned_equipped_key');
     $b = new backpack(false);
     $sortkey = 'owned';
     if ($this->request['sort'] && array_key_exists($this->request['sort'], $sort_table)) {
         $sortkey = $sort_table[$this->request['sort']];
         $this->params['sort'][$this->request['sort']] = 'selected';
     } else {
         $this->params['sort']['owned'] = 'selected';
     }
     $item_stats = cache::Memcached()->get('item_stats');
     if ($item_stats === false) {
         $json = file_get_contents($settings['cache']['folder'] . 'item_stats.json');
         $item_stats = json_decode($json, true);
         cache::Memcached()->set('item_stats', $item_stats, time() + 60 * 15);
     }
     // First. build a class->slot->items[] array for our stats
     foreach ($item_stats['items'] as $defindex => $s) {
         // Skip tokens
         if ($defindex > 5000) {
             continue;
         }
         $si = $schema['items'][$defindex];
         if (in_array($si['item_slot'], array('primary', 'secondary', 'melee', 'pda', 'pda2'))) {
             $i = $b->get_item($si);
             $i['owned'] = $s['unique_total'] / $item_stats['total_players'];
             //if($i['owned'] > 1)
             //	$i['owned'] = 1;
             if (!empty($i['used_by_classes'])) {
                 foreach ($i['used_by_classes'] as $c) {
                     $ci = class_to_int($c);
                     $i['equipped'] = $s['equipped'][$ci] / $item_stats['total_players'];
                     $i['owned_equipped'] = $s['equipped'][$ci] / $s['unique_total'];
                     $i['owned_equipped_key'] = $i['owned_equipped'] * 1000;
                     $key = $i[$sortkey];
                     while ($weapons[$c][$si['item_slot']][(string) $key] > 0) {
                         $key += 0.001;
                     }
                     $weapons[$c][$si['item_slot']][(string) $key] = $i;
                     $weapon_totals[$c][$si['item_slot']] += $i['equipped'];
                 }
             }
         }
     }
     // Now go through and combine the cosmetics defined above, as well as determine
     // stats for the 'base' weapon since valve's solution is to leave the slot
     // blank if we're using one
     foreach ($base_weapons as $class => $slots) {
         foreach ($slots as $slot => $s) {
             $si = $schema['items'][$s['base']];
             $i = $b->get_item($si);
             //$i['owned'] = ($s['total'] / $item_stats['total_players']);
             //if($i['owned'] > 1)
             //	$i['owned'] = 1;
             //$i['equipped'] = ($s['total_equipped'] / $item_stats['total_players']);
             //$i['owned_equipped'] = ($s['total_equipped'] / $s['total']);
             $i['equipped'] = 1 - $weapon_totals[$class][$slot];
             $i['owned'] = 1;
             //echo $i['equipped'];
             if (!$s['add']) {
                 continue;
             }
             foreach ($s['add'] as $a) {
                 foreach ($weapons[$class] as $csl => $t) {
                     foreach ($weapons[$class][$csl] as $k => $w) {
                         if ($w['defindex'] == $a) {
                             $sl = $csl;
                             $other = $w;
                             $key = $k;
                             break;
                         }
                     }
                 }
                 $i['equipped'] += $other['equipped'];
                 // Fix that silly rounding error causing the
                 // pipe launcher to be used by 100.01%
                 if ($i['equipped'] > 1) {
                     $i['equipped'] = 1;
                 }
                 $weapons[$class][$sl][$key]['hide'] = true;
             }
             $i['owned_equipped'] = $i['equipped'];
             $i['owned_equipped_key'] = $i['owned_equipped'] * 1000;
             $key = $i[$sortkey];
             while ($weapons[$class][$slot][(string) $key]) {
                 $key += 0.001;
             }
             $weapons[$class][$slot][(string) $key] = $i;
             unset($key);
         }
     }
     // finally, sort the results
     // Instead of wasting time sorting arrays and subarrays we can just
     // reconstruct a new array in the order of the slot array above
//.........这里部分代码省略.........
开发者ID:mwilchez,项目名称:master,代码行数:101,代码来源:weapons.view.php

示例6: prepare

 public function prepare()
 {
     global $schema, $settings;
     $this->template = "cosmetic";
     $this->tab = 'item';
     $this->title = 'Cosmetic item statistics';
     $this->canonical = 'http://tf2stats.net/misc_items/';
     $sort_table = array('owned' => 'total', 'equipped' => 'total_equipped', 'own_equip' => 'owned_equipped');
     $b = new backpack(false);
     $sortkey = 'total';
     if ($this->request['sort'] && array_key_exists($this->request['sort'], $sort_table)) {
         $sortkey = $sort_table[$this->request['sort']];
         $this->params['sort'][$this->request['sort']] = 'selected';
     } else {
         $this->params['sort']['owned'] = 'selected';
     }
     $item_stats = cache::Memcached()->get('item_stats');
     if ($item_stats === false) {
         $json = file_get_contents($settings['cache']['folder'] . 'item_stats.json');
         $item_stats = json_decode($json, true);
         cache::Memcached()->set('item_stats', $item_stats, time() + 60 * 15);
     }
     foreach ($item_stats['items'] as $defindex => $s) {
         if (in_array($defindex, $settings['items']['ignore'])) {
             continue;
         }
         $si = $schema['items'][$defindex];
         if ($si['item_slot'] == 'misc') {
             $i = $b->get_item($si);
             $i['owned'] = $s['total'] / $item_stats['total_players'];
             if ($i['owned'] > 1) {
                 $i['owned'] = 1;
             }
             $i['equipped'] = $s['total_equipped'] / $item_stats['total_players'];
             $i['owned_equipped'] = $s['total_equipped'] / $s['total'];
             $s['owned_equipped'] = intval($s['total_equipped'] / $s['total'] * 1000);
             // Colors
             arsort($s['colors']);
             foreach ($s['colors'] as $c => $num) {
                 $html = dechex($c);
                 if ($html === '0') {
                     continue;
                 }
                 //$html = '914c3f';
                 $key = $num;
                 while ($i['colors'][$key] > 0) {
                     $key++;
                 }
                 $i['colors'][$key] = array('color' => $html, 'num' => $num / $s['total_colored']);
             }
             if (count($i['used_by_classes']['class']) < 1) {
                 for ($c = 1; $c <= 9; $c++) {
                     $num = $s['equipped'][$c];
                     if ($s['total_equipped'] > 0) {
                         $i['classes'][] = array('class' => int_to_class($c), 'id' => $c, 'num' => $num / $s['total_equipped']);
                     }
                 }
             }
             $key = $s[$sortkey];
             while ($this->params['hats'][$key] > 0) {
                 $key++;
             }
             $this->params['hats'][$key] = $i;
         }
     }
     krsort($this->params['hats']);
 }
开发者ID:mwilchez,项目名称:master,代码行数:67,代码来源:misc_items.view.php

示例7: prepare

 public function prepare()
 {
     global $schema, $asset_info, $settings;
     $this->template = "item";
     $this->tab = 'item';
     $b = new backpack(false);
     $item_stats = cache::Memcached()->get('item_stats');
     if ($item_stats === false) {
         $json = file_get_contents($settings['cache']['folder'] . 'item_stats.json');
         $item_stats = json_decode($json, true);
         cache::Memcached()->set('item_stats', $item_stats, time() + 60 * 15);
     }
     cache::inc('tf2_item_info.php');
     $defindex = $this->request[1];
     $url_name = $this->request[0];
     $s = $item_stats['items'][$defindex];
     $si = $schema['items'][$defindex];
     $info = $asset_info[$defindex];
     //var_dump($info);
     $i = $b->get_item($si);
     $this->canonical = sprintf('http://tf2stats.net/item/%s/%s/', $i['name_url'], $i['defindex']);
     $i['owned'] = $s['unique_total'] / $item_stats['total_players'];
     $i['equipped'] = $s['total_equipped'] / $item_stats['total_players'];
     $i['owned_equipped'] = $s['unique_total'] > 0 ? $s['total_equipped'] / $s['unique_total'] : 0;
     // Colors
     if (!empty($s['colors'])) {
         arsort($s['colors']);
         foreach ($s['colors'] as $c => $num) {
             $id = get_paint_by_color($c);
             $si = $schema['items'][$id];
             $it = $b->get_item($si);
             $name = $it['name'];
             if (strlen($name) > 25) {
                 $name = substr($name, 0, 25) . "...";
             }
             //var_dump($it);
             $html = dechex($c);
             if ($html === '0') {
                 continue;
             }
             //$html = '914c3f';
             $key = $num;
             while ($i['colors'][$key] > 0) {
                 $key++;
             }
             $i['colors'][$key] = array('name' => $name, 'color' => $html, 'num' => $num / $s['total_colored']);
         }
     }
     // qualities
     if (!empty($s['qualities'])) {
         arsort($s['qualities']);
         foreach ($s['qualities'] as $c => $num) {
             $key = $num;
             while ($i['qualities'][$key] > 0) {
                 $key++;
             }
             $quality = int_to_quality($c);
             $label = quality_to_label($quality);
             //$color = quality_to_color($quality);
             $i['qualities'][$key] = array('color' => $color, 'num' => $num / $s['total'], 'label' => $label, 'quality' => $quality);
         }
     }
     // Origins
     if (!empty($s['origins'])) {
         arsort($s['origins']);
         foreach ($s['origins'] as $c => $num) {
             $key = $num;
             while ($i['origins'][$key] > 0) {
                 $key++;
             }
             $label = int_to_origin($c);
             //$color = quality_to_color($quality);
             $i['origins'][$key] = array('num' => $num / $s['total'], 'label' => $label);
         }
         arsort($s['effects']);
     }
     // effects
     if (!empty($s['effects'])) {
         $total_effects = 0;
         foreach ($s['effects'] as $c => $num) {
             $total_effects += $num;
         }
         foreach ($s['effects'] as $c => $num) {
             $t = $s['total_effect'] - $s['effects']['-1'];
             if ($c == -1) {
                 continue;
             }
             $key = $num;
             while ($i['effects'][$key] > 0) {
                 $key++;
             }
             $label = int_to_effect($c);
             $i['effects'][$key] = array('color' => $color, 'num' => $num / $total_effects, 'label' => $label);
         }
     }
     if (!empty($i['used_by_classes'])) {
         if (count($i['used_by_classes']['class']) < 1) {
             for ($c = 0; $c < 9; $c++) {
                 $num = $s['equipped'][$c];
                 if ($s['total_equipped'] > 0) {
//.........这里部分代码省略.........
开发者ID:mwilchez,项目名称:master,代码行数:101,代码来源:item.view.php

示例8: initialize

 function initialize($json_file = false)
 {
     global $db, $settings, $schema;
     $player = $this->player;
     $this->equipped = $this->default_loadout();
     $id = $player->id();
     $id64 = $player->id64();
     $key = 'BACKPACK_' . $id64;
     if (!$json_file) {
         global $_CACHE_ITEMS, $_CACHE_EQUIPPED;
         $cache = Cache::Memcached()->get($key);
         $this->items = $cache['items'];
         $this->equipped = $cache['equipped'];
         //var_dump($_CACHE_EQUIPPED);
         return;
     }
     $this->equipped = backpack::default_loadout();
     $json = json_decode($json_file, true);
     /*?><pre><?php
     		var_dump($json);
     		?></pre><?php*/
     if (!$json) {
         // Try forcing UTF8
         $response = utf8_encode($json_file);
         $json = json_decode($response, true);
     }
     $json_items = $json['result']['items'];
     if (!$json_items) {
         $this->error = true;
         $this->message = "Backpack is empty.";
     } else {
         foreach ($json_items as $i) {
             $items[] = $this->get_item($i);
         }
     }
     // create cache file
     $cache = array('items' => $items, 'equipped' => $this->equipped);
     $this->items = $items;
     //$this->equipped = $equipped;
     cache::Memcached()->set($key, $cache);
     //cache::clean('backpack');
 }
开发者ID:mwilchez,项目名称:master,代码行数:42,代码来源:backpack.php


注:本文中的cache::Memcached方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。