Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create dt_cuckoo.py #2976

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions doctests/dt_cuckoo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# EXAMPLE: cuckoo_tutorial
# HIDE_START
import redis

r = redis.Redis(decode_responses=True)
# HIDE_END

# REMOVE_START
r.delete("bikes:models")
# REMOVE_END

# STEP_START cuckoo
res1 = r.cf().reserve("bikes:models", 1000000)
print(res1) # >>> True

res2 = r.cf().add("bikes:models", "Smoky Mountain Striker")
print(res2) # >>> 1

res3 = r.cf().exists("bikes:models", "Smoky Mountain Striker")
print(res3) # >>> 1

res4 = r.cf().exists("bikes:models", "Terrible Bike Name")
print(res4) # >>> 0

res5 = r.cf().delete("bikes:models", "Smoky Mountain Striker")
print(res5) # >>> 1
# STEP_END

# REMOVE_START
assert res1 is True
assert res5 == 1
# REMOVE_END