pocketmine\utils\Cache::get PHP Method

get() public static method

Get something from the cache
public static get ( $identifier ) : boolean | mixed
$identifier
return boolean | mixed Returns false if not found, otherwise it returns the data
    public static function get($identifier)
    {
        if (isset(self::$cached[$identifier])) {
            self::$cached[$identifier][1] = microtime(true) + self::$cached[$identifier][2];
            return self::$cached[$identifier][0];
        }
        return false;
    }

Usage Example

コード例 #1
0
ファイル: Level.php プロジェクト: RedstoneAlmeida/Steadfast2
 protected function processChunkRequest()
 {
     if (count($this->chunkSendQueue) > 0) {
         $this->timings->syncChunkSendTimer->startTiming();
         $x = null;
         $z = null;
         foreach ($this->chunkSendQueue as $index => $players) {
             if (isset($this->chunkSendTasks[$index])) {
                 continue;
             }
             if (PHP_INT_SIZE === 8) {
                 $x = $index >> 32 << 32 >> 32;
                 $z = ($index & 4294967295.0) << 32 >> 32;
             } else {
                 list($x, $z) = explode(":", $index);
                 $x = (int) $x;
                 $z = (int) $z;
             }
             if (ADVANCED_CACHE == true and ($cache = Cache::get("world:" . $this->getId() . ":" . $index)) !== false) {
                 /** @var Player[] $players */
                 foreach ($players as $player) {
                     if ($player->isConnected() and isset($player->usedChunks[$index])) {
                         $player->sendChunk($x, $z, $cache);
                     }
                 }
                 unset($this->chunkSendQueue[$index]);
             } else {
                 $this->chunkSendTasks[$index] = true;
                 $this->timings->syncChunkSendPrepareTimer->startTiming();
                 $task = $this->provider->requestChunkTask($x, $z);
                 if ($task instanceof AsyncTask) {
                     $this->server->getScheduler()->scheduleAsyncTask($task);
                 }
                 $this->timings->syncChunkSendPrepareTimer->stopTiming();
             }
         }
         $this->timings->syncChunkSendTimer->stopTiming();
     }
 }
All Usage Examples Of pocketmine\utils\Cache::get