1
0
Fork 0
mirror of https://github.com/sileht/bird-lg.git synced 2024-11-05 07:34:42 +01:00

Allow configure asn cache expiration

This commit is contained in:
Mehdi Abaakouk 2014-04-20 17:20:52 +02:00 committed by root
parent 9822e42e25
commit 6a7bd7f228

3
lg.py
View file

@ -47,6 +47,7 @@ file_handler.setLevel(getattr(logging, app.config["LOG_LEVEL"].upper()))
app.logger.addHandler(file_handler) app.logger.addHandler(file_handler)
memcache_server = app.config.get("MEMCACHE_SERVER", "127.0.0.1:11211") memcache_server = app.config.get("MEMCACHE_SERVER", "127.0.0.1:11211")
memcache_expiration = int(app.config.get("MEMCACHE_EXPIRATION", "1296000")) # 15 days by default
mc = memcache.Client([memcache_server]) mc = memcache.Client([memcache_server])
def get_asn_from_as(n): def get_asn_from_as(n):
@ -378,7 +379,7 @@ def get_as_name(_as):
app.logger.info("asn for as %s not found in memcache", _as) app.logger.info("asn for as %s not found in memcache", _as)
name = get_asn_from_as(_as)[-1].replace(" ","\r",1) name = get_asn_from_as(_as)[-1].replace(" ","\r",1)
if name: if name:
mc.set(str("lg_%s" % _as), str(name), 3600) mc.set(str("lg_%s" % _as), str(name), memcache_expiration)
return "AS%s | %s" % (_as, name) return "AS%s | %s" % (_as, name)