File tree 2 files changed +9
-0
lines changed
2 files changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -2265,6 +2265,8 @@ def set(
2265
2265
pieces .append (int (ex .total_seconds ()))
2266
2266
elif isinstance (ex , int ):
2267
2267
pieces .append (ex )
2268
+ elif isinstance (ex , str ) and ex .isdigit ():
2269
+ pieces .append (int (ex ))
2268
2270
else :
2269
2271
raise DataError ("ex must be datetime.timedelta or int" )
2270
2272
if px is not None :
Original file line number Diff line number Diff line change @@ -1600,6 +1600,13 @@ def test_set_ex(self, r):
1600
1600
with pytest .raises (exceptions .DataError ):
1601
1601
assert r .set ("a" , "1" , ex = 10.0 )
1602
1602
1603
+ @skip_if_server_version_lt ("2.6.0" )
1604
+ def test_set_ex_str (self , r ):
1605
+ assert r .set ("a" , "1" , ex = "10" )
1606
+ assert 0 < r .ttl ("a" ) <= 10
1607
+ with pytest .raises (exceptions .DataError ):
1608
+ assert r .set ("a" , "1" , ex = "10.5" )
1609
+
1603
1610
@skip_if_server_version_lt ("2.6.0" )
1604
1611
def test_set_ex_timedelta (self , r ):
1605
1612
expire_at = datetime .timedelta (seconds = 60 )
You can’t perform that action at this time.
0 commit comments