Skip to content

Instantly share code, notes, and snippets.

@AnderRV

AnderRV/repo.py Secret

Created August 20, 2021 10:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AnderRV/797bfb64cbdd5e4e2d996dc184c121c4 to your computer and use it in GitHub Desktop.
Save AnderRV/797bfb64cbdd5e4e2d996dc184c121c4 to your computer and use it in GitHub Desktop.
from redis import Redis
connection = Redis(db=1)
to_visit_key = 'crawling:to_visit'
visited_key = 'crawling:visited'
queued_key = 'crawling:queued'
def pop_to_visit_blocking(timeout=0):
return connection.blpop(to_visit_key, timeout)
def count_visited():
return connection.scard(visited_key)
def is_queued(value):
return connection.sismember(queued_key, value)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment