Created
February 5, 2013 00:10
-
-
Save Jd007/4710980 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_geo_hash_redis_result(coord_ui, precision, cache_key, redis_db): | |
UNSIGNED_BIGINT_MAX = 18446744073709551615 | |
redis_pipe = redis_db.pipeline() | |
for hilo in geohash.expand_uint64(coord_ui, precision): | |
if hilo[0] and hilo[1]: | |
redis_pipe.zrangebyscore(cache_key, hilo[0], (hilo[1] - 1), start=None, num=None, withscores=True, score_cast_func=lambda score : long(float(score))) | |
elif hilo[0]: | |
redis_pipe.zrangebyscore(cache_key, hilo[0], UNSIGNED_BIGINT_MAX, start=None, num=None, withscores=True, score_cast_func=lambda score : long(float(score))) | |
elif hilo[1]: | |
redis_pipe.zrangebyscore(cache_key, 0, (hilo[1] - 1), start=None, num=None, withscores=True, score_cast_func=lambda score : long(float(score))) | |
results = redis_pipe.execute() | |
result_list = [] | |
for result in results: | |
result_list += result | |
return list(set(result_list)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment