Skip to content

Commit

Permalink
guild now has name_lower
Browse files Browse the repository at this point in the history
  • Loading branch information
Plancke committed Jul 31, 2018
1 parent 99caf96 commit 396aaf8
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 18 deletions.
4 changes: 2 additions & 2 deletions src/cache/CacheHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
*/
abstract class CacheHandler extends Module {

// cache time to only get cache or null if not present, arbitrary value
// cache time to only get cache or null if not present
const MAX_CACHE_TIME = PHP_INT_MAX;
// cache time to only fetch if we don't have cached data, arbitrary value
// cache time to only fetch if we don't have cached data
const MAX_CACHE_TIME_GET_NON_EXIST = CacheHandler::MAX_CACHE_TIME - 1;

protected $cacheTimes = [
Expand Down
2 changes: 1 addition & 1 deletion src/cache/impl/FlatFileCacheHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
*/
class FlatFileCacheHandler extends CacheHandler {

protected $baseDirectory = "cache" . DIRECTORY_SEPARATOR . "HypixelPHP" . DIRECTORY_SEPARATOR;
protected $baseDirectory = __DIR__ . DIRECTORY_SEPARATOR . "cache" . DIRECTORY_SEPARATOR . "HypixelPHP" . DIRECTORY_SEPARATOR;

/**
* Get base file location for all cache files
Expand Down
4 changes: 2 additions & 2 deletions src/cache/impl/MongoCacheHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function ensureIndexes() {
$db->selectCollection(CacheTypes::PLAYER_UUID)->createIndex(['name_lowercase' => 1], ['background' => true]);

$db->selectCollection(CacheTypes::GUILDS)->createIndex(['record._id' => 1], ['background' => true]);
$db->selectCollection(CacheTypes::GUILDS)->createIndex(['extra.name_lower' => 1], ['background' => true]);
$db->selectCollection(CacheTypes::GUILDS)->createIndex(['record.name_lower' => 1], ['background' => true]);
$db->selectCollection(CacheTypes::GUILDS_UUID)->createIndex(['uuid' => 1], ['background' => true]);
$db->selectCollection(CacheTypes::GUILDS_NAME)->createIndex(['name_lower' => 1], ['background' => true]);

Expand Down Expand Up @@ -275,7 +275,7 @@ function setGuildIDForName($name, $obj) {
* @return mixed|null
*/
function getGuildIDForName($name) {
$query = ['extra.name_lower' => strtolower((string)$name)];
$query = ['record.name_lower' => strtolower((string)$name)];
$data = $this->queryCollection(CacheTypes::GUILDS, $query);
if ($data != null) {
$cacheTime = $this->getCacheTime(CacheTimes::GUILD);
Expand Down
13 changes: 0 additions & 13 deletions src/responses/guild/Guild.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,6 @@ public function __construct(HypixelPHP $HypixelPHP, $guild) {
$this->members = new GuildMemberList($this->getHypixelPHP(), $this);
}

/**
* @param null $cached
* @throws \Plancke\HypixelPHP\exceptions\HypixelPHPException
*/
public function handleNew($cached = null) {
parent::handleNew($cached);

$extraSetter = [];
$extraSetter['name_lower'] = strtolower($this->getName());

$this->setExtra($extraSetter, false);
}

/**
* @return string
*/
Expand Down

0 comments on commit 396aaf8

Please sign in to comment.