From e43ebfa6c808a40c22fe08acec0df44c34d93298 Mon Sep 17 00:00:00 2001 From: vunhat_minh Date: Fri, 4 Jul 2014 15:47:41 +0900 Subject: [PATCH] reset cache --- rainbowstream/colorset/solarized.json | 2 +- rainbowstream/draw.py | 12 ++++++------ rainbowstream/rainbow.py | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/rainbowstream/colorset/solarized.json b/rainbowstream/colorset/solarized.json index 28c001d..071db1d 100644 --- a/rainbowstream/colorset/solarized.json +++ b/rainbowstream/colorset/solarized.json @@ -58,6 +58,6 @@ "CAL" : { "days": "term_64", - "today": "on_light_green" + "today": "light_green" } } diff --git a/rainbowstream/draw.py b/rainbowstream/draw.py index 60d0ef6..faf57f9 100644 --- a/rainbowstream/draw.py +++ b/rainbowstream/draw.py @@ -28,13 +28,15 @@ def init_cycle(): for i in c['CYCLE_COLOR']] return itertools.cycle(colors_shuffle) g['cyc'] = init_cycle() +g['cache'] = {} -def notify_cycle(): +def reset_cycle(): """ Notify from rainbow """ g['cyc'] = init_cycle() + g['cache'] = {} def order_rainbow(s): @@ -65,13 +67,11 @@ def Memoize(func): """ Memoize decorator """ - cache = {} - @wraps(func) def wrapper(*args): - if args not in cache: - cache[args] = func(*args) - return cache[args] + if args not in g['cache']: + g['cache'][args] = func(*args) + return g['cache'][args] return wrapper diff --git a/rainbowstream/rainbow.py b/rainbowstream/rainbow.py index fe060fb..b704287 100644 --- a/rainbowstream/rainbow.py +++ b/rainbowstream/rainbow.py @@ -799,7 +799,7 @@ def theme(): # Update db and reset colors db.theme_update(g['stuff']) c['theme'] = g['stuff'] - notify_cycle() + reset_cycle() g['decorated_name'] = color_func( c['DECORATED_NAME'])( '[@' + g['original_name'] + ']: ') -- 2.25.1