Cache daemon communication up to 60 seconds
This commit is contained in:
parent
bece1a90e7
commit
54465725af
|
@ -19,7 +19,7 @@ def json_encoder(obj):
|
||||||
|
|
||||||
class Summary:
|
class Summary:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@cache.cached(timeout=300, key_prefix="fetch_prices")
|
@cache.cached(timeout=600, key_prefix="fetch_prices")
|
||||||
def fetch_prices():
|
def fetch_prices():
|
||||||
return {
|
return {
|
||||||
'coin-btc': coin_btc_value(),
|
'coin-btc': coin_btc_value(),
|
||||||
|
@ -27,7 +27,7 @@ class Summary:
|
||||||
}
|
}
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@cache.cached(timeout=300, key_prefix="funding_stats")
|
@cache.cached(timeout=600, key_prefix="funding_stats")
|
||||||
def fetch_stats():
|
def fetch_stats():
|
||||||
from funding.factory import db
|
from funding.factory import db
|
||||||
from funding.orm.orm import Proposal, User, Comment
|
from funding.orm.orm import Proposal, User, Comment
|
||||||
|
|
|
@ -4,6 +4,7 @@ from flask import Flask
|
||||||
from flask_caching import Cache
|
from flask_caching import Cache
|
||||||
from flask_session import Session
|
from flask_session import Session
|
||||||
from flask_sqlalchemy import SQLAlchemy
|
from flask_sqlalchemy import SQLAlchemy
|
||||||
|
from werkzeug.middleware.proxy_fix import ProxyFix
|
||||||
import redis
|
import redis
|
||||||
|
|
||||||
app = None
|
app = None
|
||||||
|
@ -69,6 +70,8 @@ def create_app():
|
||||||
app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 30
|
app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 30
|
||||||
app.secret_key = settings.SECRET
|
app.secret_key = settings.SECRET
|
||||||
|
|
||||||
|
app.wsgi_app = ProxyFix(app.wsgi_app, x_proto=1, x_host=1)
|
||||||
|
|
||||||
_setup_cache(app)
|
_setup_cache(app)
|
||||||
_setup_session(app)
|
_setup_session(app)
|
||||||
_setup_db(app)
|
_setup_db(app)
|
||||||
|
|
|
@ -11,7 +11,7 @@ from sqlalchemy.types import Float
|
||||||
from sqlalchemy_json import MutableJson
|
from sqlalchemy_json import MutableJson
|
||||||
|
|
||||||
import settings
|
import settings
|
||||||
from funding.factory import db
|
from funding.factory import db, cache
|
||||||
|
|
||||||
base = declarative_base(name="Model")
|
base = declarative_base(name="Model")
|
||||||
|
|
||||||
|
@ -191,6 +191,7 @@ class Proposal(db.Model):
|
||||||
return {"amount": amount, "pct": pct}
|
return {"amount": amount, "pct": pct}
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@cache.cached(timeout=60, key_prefix="fetch_prices")
|
||||||
def balance(self):
|
def balance(self):
|
||||||
"""This property retrieves the current funding status
|
"""This property retrieves the current funding status
|
||||||
of this proposal. It uses Redis cache to not spam the
|
of this proposal. It uses Redis cache to not spam the
|
||||||
|
|
Loading…
Reference in New Issue