Skip to content

Commit

Permalink
Merge pull request #74 from gothlike/add-time-command
Browse files Browse the repository at this point in the history
Added TIME command that returns the current server time.
  • Loading branch information
fiorix committed Oct 21, 2014
2 parents 2b59bc0 + c4cdbc1 commit c56d23c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/test_operations.py
Expand Up @@ -137,3 +137,15 @@ def testRedisOperationsSet3(self):
result_2 = yield db.get(key)
self.assertEqual(result_2, "foo")
yield db.disconnect()

@defer.inlineCallbacks
def testRedisOperationTime(self):
db = yield redis.Connection(REDIS_HOST, REDIS_PORT, reconnect=False)

time = yield db.time()
self.assertIsInstance(time, list)
self.assertEqual(len(time), 2)
self.assertIsInstance(time[0], int)
self.assertIsInstance(time[1], int)

yield db.disconnect()
7 changes: 7 additions & 0 deletions txredisapi.py
Expand Up @@ -648,6 +648,13 @@ def flushall(self):
"""
return self.execute_command("FLUSHALL")

def time(self):
"""
Returns the current server time as a two items lists: a Unix timestamp
and the amount of microseconds already elapsed in the current second
"""
return self.execute_command("TIME")

# Commands operating on string values
def set(self, key, value, expire=None, pexpire=None,
only_if_not_exists=False, only_if_exists=False):
Expand Down

0 comments on commit c56d23c

Please sign in to comment.