Cache daemon communication up to 60 seconds

master
dsc 4 years ago
parent bece1a90e7
commit 54465725af

@ -19,7 +19,7 @@ def json_encoder(obj):
class Summary:
@staticmethod
@cache.cached(timeout=300, key_prefix="fetch_prices")
@cache.cached(timeout=600, key_prefix="fetch_prices")
def fetch_prices():
return {
'coin-btc': coin_btc_value(),
@ -27,7 +27,7 @@ class Summary:
}
@staticmethod
@cache.cached(timeout=300, key_prefix="funding_stats")
@cache.cached(timeout=600, key_prefix="funding_stats")
def fetch_stats():
from funding.factory import db
from funding.orm.orm import Proposal, User, Comment

@ -4,6 +4,7 @@ from flask import Flask
from flask_caching import Cache
from flask_session import Session
from flask_sqlalchemy import SQLAlchemy
from werkzeug.middleware.proxy_fix import ProxyFix
import redis
app = None
@ -69,6 +70,8 @@ def create_app():
app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 30
app.secret_key = settings.SECRET
app.wsgi_app = ProxyFix(app.wsgi_app, x_proto=1, x_host=1)
_setup_cache(app)
_setup_session(app)
_setup_db(app)

@ -11,7 +11,7 @@ from sqlalchemy.types import Float
from sqlalchemy_json import MutableJson
import settings
from funding.factory import db
from funding.factory import db, cache
base = declarative_base(name="Model")
@ -191,6 +191,7 @@ class Proposal(db.Model):
return {"amount": amount, "pct": pct}
@property
@cache.cached(timeout=60, key_prefix="fetch_prices")
def balance(self):
"""This property retrieves the current funding status
of this proposal. It uses Redis cache to not spam the

Loading…
Cancel
Save