-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
804d03d
commit beba7c0
Showing
4 changed files
with
87 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,13 +3,12 @@ | |
namespace yii1tech\psr\cache; | ||
|
||
use CComponent; | ||
use Psr\Cache\CacheItemInterface; | ||
|
||
/** | ||
* @author Paul Klimov <[email protected]> | ||
* @since 1.0 | ||
*/ | ||
class CacheItem extends CComponent implements CacheItemInterface | ||
class CacheItem extends CComponent implements CacheItemContract | ||
{ | ||
/** | ||
* @var string cache item key (ID). | ||
|
@@ -26,6 +25,11 @@ class CacheItem extends CComponent implements CacheItemInterface | |
*/ | ||
private $_expire; | ||
|
||
/** | ||
* @var \ICacheDependency|null dependency of the cache item. | ||
*/ | ||
private $_dependency; | ||
|
||
/** | ||
* Sets the key for the current cache item. | ||
* | ||
|
@@ -47,6 +51,25 @@ public function getExpire() | |
return $this->_expire; | ||
} | ||
|
||
/** | ||
* @return \ICacheDependency|null dependency of the cache item. | ||
*/ | ||
public function getDependency(): ?\ICacheDependency | ||
{ | ||
return $this->_dependency; | ||
} | ||
|
||
/** | ||
* @param \ICacheDependency|null $dependency dependency of the cache item. | ||
* @return static self reference. | ||
*/ | ||
public function setDependency(?\ICacheDependency $dependency): self | ||
{ | ||
$this->_dependency = $dependency; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
|
@@ -115,4 +138,12 @@ public function expiresAfter($time): self | |
|
||
return $this; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function depends(?\ICacheDependency $dependency): self | ||
{ | ||
return $this->setDependency($dependency); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace yii1tech\psr\cache; | ||
|
||
use Psr\Cache\CacheItemInterface; | ||
|
||
/** | ||
* @author Paul Klimov <[email protected]> | ||
* @since 1.0 | ||
*/ | ||
interface CacheItemContract extends CacheItemInterface | ||
{ | ||
/** | ||
* Sets dependency of the cached item. If the dependency changes, the item is labelled invalid. | ||
* | ||
* @param \ICacheDependency|null $dependency dependency of the cached item. | ||
* @return static self reference. | ||
*/ | ||
public function depends(?\ICacheDependency $dependency); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters