Skip to content

Commit

Permalink
Fix broken expire tests
Browse files Browse the repository at this point in the history
  • Loading branch information
byroot committed Aug 10, 2022
1 parent a48d002 commit aa594a4
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 28 deletions.
16 changes: 8 additions & 8 deletions lib/redis/distributed.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,13 @@ def persist(key)
end

# Set a key's time to live in seconds.
def expire(key, seconds)
node_for(key).expire(key, seconds)
def expire(key, seconds, **kwargs)
node_for(key).expire(key, seconds, **kwargs)
end

# Set the expiration for a key as a UNIX timestamp.
def expireat(key, unix_time)
node_for(key).expireat(key, unix_time)
def expireat(key, unix_time, **kwargs)
node_for(key).expireat(key, unix_time, **kwargs)
end

# Get the time to live (in seconds) for a key.
Expand All @@ -130,13 +130,13 @@ def ttl(key)
end

# Set a key's time to live in milliseconds.
def pexpire(key, milliseconds)
node_for(key).pexpire(key, milliseconds)
def pexpire(key, milliseconds, **kwarg)
node_for(key).pexpire(key, milliseconds, **kwarg)
end

# Set the expiration for a key as number of milliseconds from UNIX Epoch.
def pexpireat(key, ms_unix_time)
node_for(key).pexpireat(key, ms_unix_time)
def pexpireat(key, ms_unix_time, **kwarg)
node_for(key).pexpireat(key, ms_unix_time, **kwarg)
end

# Get the time to live (in milliseconds) for a key.
Expand Down
40 changes: 20 additions & 20 deletions test/lint/value_types.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,16 +111,16 @@ def test_expireat

target_version "7.0.0" do
r.set("bar", "s2")
refute r.expire_at("bar", (Time.now + 5).to_i, xx: true)
assert r.expire_at("bar", (Time.now + 5).to_i, nx: true)
refute r.expire_at("bar", (Time.now + 5).to_i, nx: true)
assert r.expire_at("bar", (Time.now + 5).to_i, xx: true)

r.expire_at("bar", 10)
refute r.expire_at("bar", (Time.now + 15).to_i, lt: true)
refute r.expire_at("bar", (Time.now + 5).to_i, gt: true)
assert r.expire_at("bar", (Time.now + 15).to_i, gt: true)
assert r.expire_at("bar", (Time.now + 5).to_i, lt: true)
refute r.expireat("bar", (Time.now + 5).to_i, xx: true)
assert r.expireat("bar", (Time.now + 5).to_i, nx: true)
refute r.expireat("bar", (Time.now + 5).to_i, nx: true)
assert r.expireat("bar", (Time.now + 5).to_i, xx: true)

r.expireat("bar", (Time.now + 10).to_i)
refute r.expireat("bar", (Time.now + 15).to_i, lt: true)
refute r.expireat("bar", (Time.now + 5).to_i, gt: true)
assert r.expireat("bar", (Time.now + 15).to_i, gt: true)
assert r.expireat("bar", (Time.now + 5).to_i, lt: true)
end
end

Expand All @@ -133,16 +133,16 @@ def test_pexpireat

target_version "7.0.0" do
r.set("bar", "s2")
refute r.expire_at("bar", (Time.now + 5).to_i * 1_000, xx: true)
assert r.expire_at("bar", (Time.now + 5).to_i * 1_000, nx: true)
refute r.expire_at("bar", (Time.now + 5).to_i * 1_000, nx: true)
assert r.expire_at("bar", (Time.now + 5).to_i * 1_000, xx: true)

r.expire_at("bar", 10)
refute r.expire_at("bar", (Time.now + 15).to_i * 1_000, lt: true)
refute r.expire_at("bar", (Time.now + 5).to_i * 1_000, gt: true)
assert r.expire_at("bar", (Time.now + 15).to_i * 1_000, gt: true)
assert r.expire_at("bar", (Time.now + 5).to_i * 1_000, lt: true)
refute r.pexpireat("bar", (Time.now + 5).to_i * 1_000, xx: true)
assert r.pexpireat("bar", (Time.now + 5).to_i * 1_000, nx: true)
refute r.pexpireat("bar", (Time.now + 5).to_i * 1_000, nx: true)
assert r.pexpireat("bar", (Time.now + 5).to_i * 1_000, xx: true)

r.pexpireat("bar", (Time.now + 10).to_i * 1_000)
refute r.pexpireat("bar", (Time.now + 15).to_i * 1_000, lt: true)
refute r.pexpireat("bar", (Time.now + 5).to_i * 1_000, gt: true)
assert r.pexpireat("bar", (Time.now + 15).to_i * 1_000, gt: true)
assert r.pexpireat("bar", (Time.now + 5).to_i * 1_000, lt: true)
end
end

Expand Down

0 comments on commit aa594a4

Please sign in to comment.