def check_geocache(): """ Geocache is relevant only when geocoding usage is enabled. """ use_geocoding = os.environ.get('USE_GEOCODING', False) if not use_geocoding: return {'status': 'pass'} from geocoding.geocache import GeoCodingCache host = os.environ.get('REDIS_HOST', None) port = os.environ.get('REDIS_PORT', 6379) gc = GeoCodingCache(host, port) health = gc.get_health() return health
def add_geodata(entity): # TODO: Move this setting to configuration (See GH issue #10) use_geocoding = os.environ.get('USE_GEOCODING', False) redis_host = os.environ.get('REDIS_HOST', None) # No cache -> no geocoding by default if use_geocoding and redis_host: redis_port = os.environ.get('REDIS_PORT', 6379) cache = GeoCodingCache(redis_host, redis_port) from geocoding import geocoding geocoding.add_location(entity, cache=cache)