Skip to content

Commit a6b9cc7

Browse files
committed
Add cache keys to config
1 parent 055b504 commit a6b9cc7

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

app.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@
1414
app.config.from_object('config.Config')
1515
db = SQLAlchemy(app)
1616
migrate = Migrate(app, db)
17-
18-
cache = Cache(config={'CACHE_TYPE': 'SimpleCache', 'CACHE_DEFAULT_TIMEOUT' : 300})
19-
cache.init_app(app)
17+
cache = Cache(app)
2018

2119
class UserModel(db.Model):
2220
id = db.Column(db.Integer, primary_key=True)
@@ -76,7 +74,7 @@ def get(self, user_id):
7674
class Users(Resource):
7775
@app.route("/")
7876
def index():
79-
return redirect('/users')
77+
return redirect('/users')
8078

8179
@cache.cached(query_string=True)
8280
@marshal_with(resource_fields)

config.py

+3
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,6 @@ class Config:
1616
SQLALCHEMY_TABLE = 'migrations'
1717
SQLALCHEMY_DB_SCHEMA = 'public'
1818
SQLALCHEMY_TRACK_MODIFICATIONS = False
19+
20+
CACHE_TYPE = 'SimpleCache'
21+
CACHE_DEFAULT_TIMEOUT = 300

0 commit comments

Comments
 (0)