@@ -398,7 +398,9 @@ private function saveRemediationsForCacheKey(array $decisions, string $cacheKey)
398398 /**
399399 * Cache key convention.
400400 *
401- * @throws Exception
401+ * @param string $scope
402+ * @param string $value
403+ * @return string
402404 */
403405 private function getCacheKey (string $ scope , string $ value ): string
404406 {
@@ -638,7 +640,7 @@ public function clear(): bool
638640 *
639641 * @return array "count": number of decisions added, "errors": decisions not added
640642 *
641- * @throws InvalidArgumentException
643+ * @throws InvalidArgumentException|\Psr\Cache\CacheException
642644 */
643645 public function warmUp (): array
644646 {
@@ -968,7 +970,7 @@ private function getIpCachedVariables(string $cacheTag, string $ip)
968970 * @return array
969971 * @throws InvalidArgumentException
970972 */
971- public function getIpVariables ($ cacheTag , $ names , $ ip ): array
973+ public function getIpVariables (string $ cacheTag , array $ names , string $ ip ): array
972974 {
973975 $ cachedVariables = $ this ->getIpCachedVariables ($ cacheTag , $ ip );
974976 $ variables = [];
@@ -998,13 +1000,7 @@ public function setIpVariables(string $cacheTag, array $pairs, string $ip)
9981000 foreach ($ pairs as $ name => $ value ) {
9991001 $ cachedVariables [$ name ] = $ value ;
10001002 }
1001- $ duration = (Constants::CACHE_TAG_CAPTCHA === $ cacheTag )
1002- ? $ this ->cacheExpirationForCaptcha : $ this ->cacheExpirationForGeo ;
1003- $ item = $ this ->adapter ->getItem (base64_encode ($ cacheKey ));
1004- $ item ->set ($ cachedVariables );
1005- $ item ->expiresAt (new DateTime ("+ $ duration seconds " ));
1006- $ item ->tag ($ cacheTag );
1007- $ this ->adapter ->save ($ item );
1003+ $ this ->saveCacheItem ($ cacheTag , $ cacheKey , $ cachedVariables );
10081004 }
10091005
10101006 /**
@@ -1024,6 +1020,19 @@ public function unsetIpVariables(string $cacheTag, array $pairs, string $ip)
10241020 foreach ($ pairs as $ name => $ value ) {
10251021 unset($ cachedVariables [$ name ]);
10261022 }
1023+ $ this ->saveCacheItem ($ cacheTag , $ cacheKey , $ cachedVariables );
1024+ }
1025+
1026+ /**
1027+ * @param string $cacheTag
1028+ * @param string $cacheKey
1029+ * @param $cachedVariables
1030+ * @return void
1031+ * @throws InvalidArgumentException
1032+ * @throws \Psr\Cache\CacheException
1033+ */
1034+ protected function saveCacheItem (string $ cacheTag , string $ cacheKey , $ cachedVariables ): void
1035+ {
10271036 $ duration = (Constants::CACHE_TAG_CAPTCHA === $ cacheTag )
10281037 ? $ this ->cacheExpirationForCaptcha : $ this ->cacheExpirationForGeo ;
10291038 $ item = $ this ->adapter ->getItem (base64_encode ($ cacheKey ));
0 commit comments