Skip to content

Commit

Permalink
correct term "prune" instead of "flush"
Browse files Browse the repository at this point in the history
  • Loading branch information
SQKo committed Aug 13, 2023
1 parent 77f9cc3 commit b34811b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions src/Discord/Helpers/CacheWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -476,19 +476,19 @@ public function unserializer($value)
}

/**
* Flush deleted items from cache and weaken items. Items with Bot's ID are
* Prune deleted items from cache and weaken items. Items with Bot's ID are
* exempt.
*
* @return int Flushed items.
* @return int Pruned items.
*/
public function sweep(): int
{
$flushing = 0;
$pruning = 0;
foreach ($this->items as $key => $item) {
if (null === $item) {
// Item was removed from memory, delete from cache
$this->delete($key);
$flushing++;
$pruning++;
} elseif ($item instanceof Part) {
// Skip ID related to Bot
if ($key != $this->discord->id) {
Expand All @@ -497,11 +497,11 @@ public function sweep(): int
}
}
}
if ($flushing) {
$this->discord->getLogger()->debug('Flushing repository cache', ['count' => $flushing, 'class' => $this->class]);
if ($pruning) {
$this->discord->getLogger()->debug('Pruning repository cache', ['count' => $pruning, 'class' => $this->class]);
}

return $flushing;
return $pruning;
}

public function __get(string $name)
Expand Down
2 changes: 1 addition & 1 deletion src/Discord/Repository/AbstractRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ public function find(callable $callback)
*/
public function clear(): void
{
// Set items null but keep the keys to be removed on flush
// Set items null but keep the keys to be removed on prune
$this->items = array_fill_keys(array_keys($this->items), null);
}

Expand Down

0 comments on commit b34811b

Please sign in to comment.