Skip to content

Commit

Permalink
add new interfaces expire and exists (sonic-net#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
keboliu authored and lguohan committed Aug 17, 2018
1 parent ca540c9 commit 6272b5f
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/swsssdk/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,20 @@ def publish(self, db_name, channel, message):
client = self.redis_clients[db_name]
return client.publish(channel, message)

def expire(self, db_name, key, timeout_sec):
"""
Set a timeout on a key
"""
client = self.redis_clients[db_name]
return client.expire(key, timeout_sec)

def exists(self, db_name, key):
"""
Check if a key exist in the db
"""
client = self.redis_clients[db_name]
return client.exists(key)

@blockable
def keys(self, db_name, pattern='*'):
"""
Expand Down

0 comments on commit 6272b5f

Please sign in to comment.