forked from unikent/taggedFileCache
-
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.
修复指定队列无效的bug;
- Loading branch information
Showing
4 changed files
with
92 additions
and
76 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
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 |
---|---|---|
@@ -1,45 +1,53 @@ | ||
<?php | ||
|
||
namespace Unikent\Cache; | ||
|
||
use Illuminate\Cache\TagSet; | ||
use Unikent\Jobs\FlushTagFromFileCacheJob; | ||
|
||
class FileTagSet extends TagSet{ | ||
|
||
protected static $driver = 'tfile'; | ||
|
||
/** | ||
* Get the tag identifier key for a given tag. | ||
* | ||
* @param string $name | ||
* @return string | ||
*/ | ||
public function tagKey($name) | ||
{ | ||
return 'cache_tags' . $this->store->separator . preg_replace('/[^\w\s\d\-_~,;\[\]\(\).]/', '~', $name); | ||
} | ||
|
||
|
||
/** | ||
* Reset the tag and return the new tag identifier. | ||
* | ||
* @param string $name | ||
* @return string | ||
*/ | ||
public function resetTag($name) | ||
{ | ||
|
||
$oldID = $this->store->get($this->tagKey($name)); | ||
|
||
if ($oldID!==false){ | ||
$job = new FlushTagFromFileCacheJob($oldID, static::$driver); | ||
if(!empty($this->store->queue)){ | ||
$job->onQueue($this->store->queue); | ||
} | ||
dispatch($job); | ||
} | ||
|
||
return parent::resetTag($name); | ||
} | ||
class FileTagSet extends TagSet | ||
{ | ||
|
||
protected static $driver = 'tfile'; | ||
|
||
/** | ||
* Get the tag identifier key for a given tag. | ||
* | ||
* @param string $name | ||
* @return string | ||
*/ | ||
public function tagKey($name) | ||
{ | ||
return 'cache_tags' . $this->store->separator . preg_replace('/[^\w\s\d\-_~,;\[\]\(\).]/', '~', $name); | ||
} | ||
|
||
|
||
/** | ||
* Reset the tag and return the new tag identifier. | ||
* | ||
* @param string $name | ||
* @return string | ||
*/ | ||
public function resetTag($name) | ||
{ | ||
|
||
$oldID = $this->store->get($this->tagKey($name)); | ||
|
||
if ($oldID !== false) { | ||
$job = new FlushTagFromFileCacheJob($oldID, static::$driver); | ||
|
||
if (!empty($this->store->connection)) { | ||
$job->onConnection($this->store->connection); | ||
} | ||
|
||
if (!empty($this->store->queue)) { | ||
$job->onQueue($this->store->queue); | ||
} | ||
|
||
dispatch($job); | ||
} | ||
|
||
return parent::resetTag($name); | ||
} | ||
|
||
} |
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