Skip to content

Commit

Permalink
Use existence test + get w/expires storage.
Browse files Browse the repository at this point in the history
Fixes #531
  • Loading branch information
coleifer committed Jun 18, 2020
1 parent b9cb866 commit 335c5dc
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions huey/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -516,8 +516,11 @@ def put_data(self, key, value, is_result=False):
self.conn.set(self.result_key(key), value)

def peek_data(self, key):
res = self.conn.get(self.result_key(key))
return res if res is not None else EmptyData
pipe = self.conn.pipeline()
pipe.exists(self.result_key(key))
pipe.get(self.result_key(key))
exists, val = pipe.execute()
return EmptyData if not exists else val

# Here we explicitly prevent result items from being removed by using the
# same implementation for "pop" (get and delete) as we do for "peek"
Expand Down

0 comments on commit 335c5dc

Please sign in to comment.