File tree Expand file tree Collapse file tree 2 files changed +9
-0
lines changed Expand file tree Collapse file tree 2 files changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -2265,6 +2265,8 @@ def set(
22652265 pieces .append (int (ex .total_seconds ()))
22662266 elif isinstance (ex , int ):
22672267 pieces .append (ex )
2268+ elif isinstance (ex , str ) and ex .isdigit ():
2269+ pieces .append (int (ex ))
22682270 else :
22692271 raise DataError ("ex must be datetime.timedelta or int" )
22702272 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):
16001600 with pytest .raises (exceptions .DataError ):
16011601 assert r .set ("a" , "1" , ex = 10.0 )
16021602
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+
16031610 @skip_if_server_version_lt ("2.6.0" )
16041611 def test_set_ex_timedelta (self , r ):
16051612 expire_at = datetime .timedelta (seconds = 60 )
You can’t perform that action at this time.
0 commit comments