add() public static method

Adds something to the cache
public static add ( string $identifier, mixed $blob, float | integer $minTTL = 30 )
$identifier string
$blob mixed
$minTTL float | integer The data will remain cached for at least $minTTL seconds
Exemplo n.º 1
0
 public function chunkRequestCallback($x, $z, $payload)
 {
     $index = PHP_INT_SIZE === 8 ? ($x & 4294967295.0) << 32 | $z & 4294967295.0 : $x . ":" . $z;
     if (isset($this->chunkSendTasks[$index])) {
         if (ADVANCED_CACHE == true) {
             Cache::add("world:" . $this->getId() . ":" . $index, $payload, 60);
         }
         foreach ($this->chunkSendQueue[$index] as $player) {
             /** @var Player $player */
             if ($player->isConnected() and isset($player->usedChunks[$index])) {
                 $player->sendChunk($x, $z, $payload);
             }
         }
         unset($this->chunkSendQueue[$index]);
         unset($this->chunkSendTasks[$index]);
     }
 }
Exemplo n.º 2
0
 public function chunkRequestCallback($x, $z, $payload)
 {
     $index = Level::chunkHash($x, $z);
     if (isset($this->chunkSendTasks[$index])) {
         if (ADVANCED_CACHE == true) {
             Cache::add("world:" . $this->getID() . ":" . $index, $payload, 60);
         }
         foreach ($this->chunkSendQueue[$index] as $player) {
             /** @var Player $player */
             if (isset($player->usedChunks[$index])) {
                 $player->sendChunk($x, $z, $payload);
             }
         }
         unset($this->chunkSendQueue[$index]);
         unset($this->chunkSendTasks[$index]);
     }
 }