Skip to content

Commit

Permalink
Deprecated cache fields
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonOkulov committed May 14, 2019
1 parent 108f937 commit 09abdde
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 15 deletions.
2 changes: 2 additions & 0 deletions src/Phact/Orm/Configuration/ConfigurationManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public function __construct(

/**
* @return int
* @deprecated
*/
public function setCacheFieldsTimeout(?int $timeout): self
{
Expand All @@ -73,6 +74,7 @@ public function setCacheFieldsTimeout(?int $timeout): self

/**
* @return int
* @deprecated
*/
public function getCacheFieldsTimeout(): ?int
{
Expand Down
4 changes: 4 additions & 0 deletions src/Phact/Orm/Configuration/ConfigurationManagerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@

interface ConfigurationManagerInterface
{
/**
* @deprecated
* @return int|null
*/
public function getCacheFieldsTimeout(): ?int;
public function getCacheQueryTimeout(): ?int;
public function getContainer(): ContainerInterface;
Expand Down
16 changes: 1 addition & 15 deletions src/Phact/Orm/FieldsManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,7 @@ class FieldsManager

public static function makeInstance($modelClass, $fields, $metaData = [])
{
$configuration = ConfigurationProvider::getInstance()->getManager();
$cache = $configuration->getCache();
$key = 'PHACT__FIELDS_MANAGER_' . $modelClass;
$manager = null;
$cacheTimeout = $configuration->getCacheFieldsTimeout();
if ($cache && $cacheTimeout !== null) {
$manager = $cache->get($key);
}
if (!$manager) {
$manager = new self($modelClass, $fields, $metaData);
if ($cache && $cacheTimeout !== null) {
$cache->set($key, $manager, $cacheTimeout);
}
}
return $manager;
return new self($modelClass, $fields, $metaData);
}

public function __construct($modelClass, $fields, $metaData = [])
Expand Down

0 comments on commit 09abdde

Please sign in to comment.