#13 Replace werkzeug SimpleCache by flask-caching
Merged 3 years ago by frantisekz. Opened 3 years ago by frantisekz.

file modified
+2 -1
@@ -1,10 +1,11 @@ 

- Werkzeug < 1.0.0

+ Werkzeug

  Flask

  Flask-SQLAlchemy

  SQLAlchemy

  WTForms

  Flask-WTF

  Flask-Login

+ Flask-Caching

  alembic

  resultsdb-api

  python-fedora

file modified
+1
@@ -19,6 +19,7 @@ 

  Requires:       python3-flask-sqlalchemy

  Requires:       python3-flask-wtf

  Requires:       python3-flask-login

+ Requires:       python3-flask-caching

  Requires:       python3-alembic

  Requires:       python3-fedora

  Requires:       python3-resultsdb_api

file modified
+2 -3
@@ -51,13 +51,12 @@ 

  

  

  # TODO: use Memcached instead of SimpleCache

- from werkzeug.contrib.cache import SimpleCache

- CACHE = SimpleCache()

+ from flask_caching import Cache

+ CACHE = Cache(app, config={'CACHE_TYPE': 'simple'})

  CACHE_TIMEOUT = 10

  

  def preparse_results(event):

      global CACHE

- 

      cached = CACHE.get("event_%s_matrix" % event.id)

      if cached is not None:

          return cached

no initial comment

Also, the flask-caching Cache needs to be set with an app object (https://pythonhosted.org/Flask-Cache/#set-up) Looks to me like you either are running some weird code, that is not really flask-caching, or you forgot to try and run/test the code after you made the changes ;)

I just noticed the "not tested yet" comment. I'd appreciate if you used "WIP" or something like that right in the PR's title, next time, like you do in Oraculum, for example, so I don't need to get into the "how the hell can this work for him" rabbit hole :)

rebased onto b837055

3 years ago

I've fixed this mess, really sorry for not properly marking it as WIP.

It seems it works as it should now, data gets loaded from cache and there are no fires to put out.

:thumbsup: thanks! LGTM

Pull-Request has been merged by frantisekz

3 years ago