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)
74
74
if ($ item instanceof Item) {
75
75
$ ttl = $ item ->getExpirationDate ()->getTimestamp () - time ();
76
76
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
+ }
78
86
} else {
79
87
throw new \InvalidArgumentException ('Cross-Driver type confusion detected ' );
80
88
}
Original file line number Diff line number Diff line change @@ -65,7 +65,15 @@ protected function driverWrite(CacheItemInterface $item)
65
65
if ($ item instanceof Item) {
66
66
$ ttl = $ item ->getExpirationDate ()->getTimestamp () - time ();
67
67
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
+ }
69
77
} else {
70
78
throw new \InvalidArgumentException ('Cross-Driver type confusion detected ' );
71
79
}
You can’t perform that action at this time.
0 commit comments