2
2
3
3
namespace Overtrue \LaravelPassportCacheToken ;
4
4
5
+ use Illuminate \Cache \TaggableStore ;
6
+ use Illuminate \Contracts \Cache \Repository ;
5
7
use Illuminate \Database \Eloquent \Collection ;
6
8
use Laravel \Passport \Passport ;
7
9
use Laravel \Passport \Token ;
@@ -53,7 +55,7 @@ public function __construct(string $cacheKeyPrefix = null, int $expiresInSeconds
53
55
*/
54
56
public function find ($ id )
55
57
{
56
- return Cache:: store ( $ this ->cacheStore )-> tags ( $ this -> cacheTags )->remember (
58
+ return $ this ->store ( )->remember (
57
59
$ this ->itemKey ($ id ),
58
60
\now ()->addSeconds ($ this ->expiresInSeconds ),
59
61
function () use ($ id ) {
@@ -72,7 +74,7 @@ function () use ($id) {
72
74
*/
73
75
public function findForUser ($ id , $ userId )
74
76
{
75
- return Cache:: store ( $ this ->cacheStore )-> tags ( $ this -> cacheTags )->remember (
77
+ return $ this ->store ( )->remember (
76
78
$ this ->itemKey ($ id ),
77
79
\now ()->addSeconds ($ this ->expiresInSeconds ),
78
80
function () use ($ id , $ userId ) {
@@ -90,7 +92,7 @@ function () use ($id, $userId) {
90
92
*/
91
93
public function forUser ($ userId ): Collection
92
94
{
93
- return Cache:: store ( $ this ->cacheStore )-> tags ( $ this -> cacheTags )->remember (
95
+ return $ this ->store ( )->remember (
94
96
$ this ->itemKey ($ userId ),
95
97
\now ()->addSeconds ($ this ->expiresInSeconds ),
96
98
function () use ($ userId ) {
@@ -109,7 +111,7 @@ function () use ($userId) {
109
111
*/
110
112
public function getValidToken ($ user , $ client )
111
113
{
112
- return Cache:: store ( $ this ->cacheStore )-> tags ( $ this -> cacheTags )->remember (
114
+ return $ this ->store ( )->remember (
113
115
$ this ->itemKey ($ user ->getKey ()),
114
116
\now ()->addSeconds ($ this ->expiresInSeconds ),
115
117
function () use ($ client , $ user ) {
@@ -126,4 +128,11 @@ public function itemKey(string $key)
126
128
{
127
129
return $ this ->cacheKeyPrefix . $ key ;
128
130
}
131
+
132
+ public function store (): Repository
133
+ {
134
+ $ store = Cache::store ($ this ->cacheStore );
135
+
136
+ return $ store instanceof TaggableStore ? $ store ->tags ($ this ->cacheTags ) : $ store ;
137
+ }
129
138
}
0 commit comments