Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
rising: Use g.gencache
Browse files Browse the repository at this point in the history
  • Loading branch information
bsimpson63 committed Jun 20, 2016
1 parent 7530395 commit 18fb269
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
1 change: 1 addition & 0 deletions install/setup_mcrouter.sh
Expand Up @@ -77,6 +77,7 @@ if [ ! -f /etc/mcrouter/global.conf ]; then
"geoip:": "local-pool",
"geopromo:": "local-pool",
"srpromos:": "local-pool",
"rising:": "local-pool",
},
"wildcard": {
"type": "PoolRoute",
Expand Down
17 changes: 10 additions & 7 deletions r2/r2/lib/rising.py
Expand Up @@ -30,9 +30,6 @@
from r2.models.link import Link


CACHE_KEY = "rising"


def calc_rising():
link_counts = count.get_link_counts()

Expand All @@ -53,11 +50,12 @@ def score(link):


def set_rising():
g.cache.set(CACHE_KEY, calc_rising())
# TODO: spread this around to several keys
g.gencache.set("rising:all", calc_rising())


def get_all_rising():
return g.cache.get(CACHE_KEY, [])
return g.gencache.get("rising:all", [])


def get_rising(sr):
Expand Down Expand Up @@ -88,8 +86,13 @@ def normalized_rising(sr_ids):
if not sr_ids:
return []

tuples_by_srid = sgm(g.cache, sr_ids, miss_fn=get_rising_tuples,
prefix='normalized_rising', time=g.page_cache_time)
tuples_by_srid = sgm(
cache=g.gencache,
keys=sr_ids,
miss_fn=get_rising_tuples,
prefix='rising:',
time=g.page_cache_time,
)

merged = heapq.merge(*tuples_by_srid.values())

Expand Down

0 comments on commit 18fb269

Please sign in to comment.