33namespace ForFit \Mongodb \Cache ;
44
55use Closure ;
6- use Illuminate \Support \InteractsWithTime ;
76use Illuminate \Cache \RetrievesMultipleKeys ;
8- use Illuminate \Database \ConnectionInterface ;
97use Illuminate \Contracts \Cache \Store as StoreInterface ;
8+ use Illuminate \Database \ConnectionInterface ;
9+ use Illuminate \Support \InteractsWithTime ;
1010use Jenssegers \Mongodb \Query \Builder ;
1111use MongoDB \BSON \UTCDateTime ;
1212use MongoDB \Driver \Exception \BulkWriteException ;
@@ -107,15 +107,15 @@ public function decrement($key, $value = 1)
107107 /**
108108 * @inheritDoc
109109 */
110- public function forever ($ key , $ value )
110+ public function forever ($ key , $ value ): bool
111111 {
112112 return $ this ->put ($ key , $ value , 315360000 );
113113 }
114114
115115 /**
116116 * @inheritDoc
117117 */
118- public function forget ($ key )
118+ public function forget ($ key ): bool
119119 {
120120 $ this ->table ()->where ('key ' , '= ' , $ this ->getPrefix () . $ key )->delete ();
121121
@@ -125,7 +125,7 @@ public function forget($key)
125125 /**
126126 * @inheritDoc
127127 */
128- public function flush ()
128+ public function flush (): bool
129129 {
130130 $ this ->table ()->delete ();
131131
@@ -135,29 +135,23 @@ public function flush()
135135 /**
136136 * @inheritDoc
137137 */
138- public function getPrefix ()
138+ public function getPrefix (): string
139139 {
140140 return $ this ->prefix ;
141141 }
142142
143143 /**
144144 * Sets the tags to be used
145- *
146- * @param array $tags
147- * @return MongoTaggedCache
148145 */
149- public function tags (array $ tags )
146+ public function tags (array $ tags ): MongoTaggedCache
150147 {
151148 return new MongoTaggedCache ($ this , $ tags );
152149 }
153150
154151 /**
155152 * Deletes all records with the given tag
156- *
157- * @param array $tags
158- * @return void
159153 */
160- public function flushByTags (array $ tags )
154+ public function flushByTags (array $ tags ): void
161155 {
162156 foreach ($ tags as $ tag ) {
163157 $ this ->table ()->where ('tags ' , $ tag )->delete ();
@@ -166,11 +160,8 @@ public function flushByTags(array $tags)
166160
167161 /**
168162 * Retrieve an item's expiration time from the cache by key.
169- *
170- * @param string $key
171- * @return null|float|int
172163 */
173- public function getExpiration ($ key )
164+ public function getExpiration ($ key ): ? float
174165 {
175166 $ cacheData = $ this ->table ()->where ('key ' , $ this ->getKeyWithPrefix ($ key ))->first ();
176167
@@ -199,7 +190,7 @@ protected function table()
199190 * @param string $key
200191 * @return string
201192 */
202- protected function getKeyWithPrefix (string $ key )
193+ protected function getKeyWithPrefix (string $ key ): string
203194 {
204195 return $ this ->getPrefix () . $ key ;
205196 }
@@ -210,7 +201,7 @@ protected function getKeyWithPrefix(string $key)
210201 * @param string $key
211202 * @param int $value
212203 * @param Closure $callback
213- * @return int|bool
204+ * @return false|mixed
214205 */
215206 protected function incrementOrDecrement ($ key , $ value , Closure $ callback )
216207 {
0 commit comments