davanstrien HF staff commited on
Commit
4789079
·
1 Parent(s): 84fa5c4

more caching

Browse files
Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -43,16 +43,18 @@ def relative_rank(my_dict, target_key, filter_zero=False):
43
  }
44
 
45
 
 
46
  def relative_rank_for_space(space_id, filter_zero=False):
47
  space_to_like_dict = create_space_to_like_dict()
48
  return relative_rank(space_to_like_dict, space_id, filter_zero=filter_zero)
49
 
50
 
 
51
  def relative_rank_for_org(org_id, filter_zero=False):
52
  org_to_like_dict = create_org_to_like_dict()
53
  return relative_rank(org_to_like_dict, org_id, filter_zero=filter_zero)
54
 
55
-
56
  def rank_space(space_id):
57
  return relative_rank_for_space(space_id)
58
 
@@ -76,7 +78,7 @@ with gr.Blocks() as demo:
76
  """<p style='text-align: center;'>Rank a single Space or all of the Spaces created by an organization or user by likes</p>"""
77
  )
78
  gr.HTML(
79
- """<p style="text-align: center;"><i>Remember likes aren't everything!iii></>"""
80
  )
81
  gr.Markdown(
82
  """## Rank Spaces
 
43
  }
44
 
45
 
46
+ @cached(cache=TTLCache(maxsize=100, ttl=60 * 3))
47
  def relative_rank_for_space(space_id, filter_zero=False):
48
  space_to_like_dict = create_space_to_like_dict()
49
  return relative_rank(space_to_like_dict, space_id, filter_zero=filter_zero)
50
 
51
 
52
+ @cached(cache=TTLCache(maxsize=100, ttl=60 * 3))
53
  def relative_rank_for_org(org_id, filter_zero=False):
54
  org_to_like_dict = create_org_to_like_dict()
55
  return relative_rank(org_to_like_dict, org_id, filter_zero=filter_zero)
56
 
57
+ @cached(cache=TTLCache(maxsize=100, ttl=60 * 3))
58
  def rank_space(space_id):
59
  return relative_rank_for_space(space_id)
60
 
 
78
  """<p style='text-align: center;'>Rank a single Space or all of the Spaces created by an organization or user by likes</p>"""
79
  )
80
  gr.HTML(
81
+ """<p style="text-align: center;"><i>Remember likes aren't everything!iii></"""
82
  )
83
  gr.Markdown(
84
  """## Rank Spaces