Skip to content

Commit

Permalink
Merge pull request #190 from ngnpope/fix-delete-return
Browse files Browse the repository at this point in the history
delete() return value now is 1 for "DELETED" and 0 for "NOT_FOUND" or server error.
  • Loading branch information
linsomniac authored Jan 3, 2024
2 parents deac889 + c9a1626 commit 880fe69
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions memcache.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,9 +552,9 @@ def delete(self, key, noreply=False):
if noreply:
return 1
line = server.readline()
if line and line.strip() in [b'DELETED', b'NOT_FOUND']:
if line and line.strip() == b'DELETED':
return 1
self.debuglog('delete expected DELETED or NOT_FOUND, got: {!r}'.format(line))
self.debuglog('delete expected DELETED, got: {!r}'.format(line))
except OSError as msg:
if isinstance(msg, tuple):
msg = msg[1]
Expand Down
2 changes: 2 additions & 0 deletions tests/test_memcache.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ def test_delete(self):
result = self.mc.delete("long")
self.assertEqual(result, True)
self.assertEqual(self.mc.get("long"), None)
result = self.mc.delete("<missing>")
self.assertEqual(result, False)

def test_default(self):
key = "default"
Expand Down

0 comments on commit 880fe69

Please sign in to comment.