File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -74,7 +74,15 @@ protected function driverWrite(CacheItemInterface $item)
7474 if ($ item instanceof Item) {
7575 $ ttl = $ item ->getExpirationDate ()->getTimestamp () - time ();
7676
77- return $ this ->instance ->setex ($ item ->getKey (), $ ttl , $ this ->encode ($ this ->driverPreWrap ($ item )));
77+ /**
78+ * @see https://redis.io/commands/setex
79+ * @see https://redis.io/commands/expire
80+ */
81+ if ($ ttl <= 0 ){
82+ return $ this ->instance ->expire ($ item ->getKey (), 0 );
83+ }else {
84+ return $ this ->instance ->setex ($ item ->getKey (), $ ttl , $ this ->encode ($ this ->driverPreWrap ($ item )));
85+ }
7886 } else {
7987 throw new \InvalidArgumentException ('Cross-Driver type confusion detected ' );
8088 }
Original file line number Diff line number Diff line change @@ -65,7 +65,15 @@ protected function driverWrite(CacheItemInterface $item)
6565 if ($ item instanceof Item) {
6666 $ ttl = $ item ->getExpirationDate ()->getTimestamp () - time ();
6767
68- return $ this ->instance ->setex ($ item ->getKey (), $ ttl , $ this ->encode ($ this ->driverPreWrap ($ item )));
68+ /**
69+ * @see https://redis.io/commands/setex
70+ * @see https://redis.io/commands/expire
71+ */
72+ if ($ ttl <= 0 ){
73+ return $ this ->instance ->expire ($ item ->getKey (), 0 );
74+ }else {
75+ return $ this ->instance ->setex ($ item ->getKey (), $ ttl , $ this ->encode ($ this ->driverPreWrap ($ item )));
76+ }
6977 } else {
7078 throw new \InvalidArgumentException ('Cross-Driver type confusion detected ' );
7179 }
You can’t perform that action at this time.
0 commit comments