Skip to content

Commit

Permalink
改进DataMapper\Cache\Hook::getCacheKey(),允许通过配置自定义cache key
Browse files Browse the repository at this point in the history
  • Loading branch information
yeaha committed Jun 1, 2016
1 parent 0b542d2 commit e04e04c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/DataMapper/Cache/Hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,15 @@ protected function getCacheService($key)
*/
protected function getCacheKey($id)
{
$prefix = sprintf('entity:%s@', str_replace('\\', ':', trim($this->class, '\\')));
$prefix = $this->hasOption('cache_key')
? $this->getOption('cache_key')
: sprintf('entity:%s', str_replace('\\', ':', trim($this->class, '\\')));

$prefix = $prefix.'@';

if ($this->hasOption('cache_key_prefix')) {
$prefix = $this->getOption('cache_key_prefix').':'.$prefix;
}

if (is_array($id)) {
ksort($id);
Expand Down

0 comments on commit e04e04c

Please sign in to comment.