{ "info": { "author": "Mrkiven", "author_email": "kiven.mr@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "Ecache for sqlalchemy\n=====================\n\n\nRun test\n--------\n\n.. code:: bash\n\n make unittest\n\n\nInstallation / Rquirements\n--------------------------\n\n.. code::\n\n pip intall ecache\n\n\nUsage\n-----\n\nWith Flask Integrate\n~~~~~~~~~~~~~~~~~~~~\n\n.. code:: python\n\n from flask import Flask, jsonify\n from flask_sqlalchemy import SQLAlchemy\n\n from ecache.ext.flask_cache import CacheableMixin, query_callable, regions\n\n app = Flask(__name__)\n app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////tmp/test.db'\n app.debug = True\n db = SQLAlchemy(app)\n\n class User(db.Model, CacheableMixin):\n \"\"\"Default backend is redis and expiration time is 1 hour, default\n region name is `default`, you can override this:\n\n cache_regions = your_regions\n cache_label = your_label\n \"\"\"\n\n id = db.Column(db.Integer, primary_key=True)\n name = db.Column(db.String)\n\n @app.route('/users')\n def all_users():\n \"\"\"Result will try to get from cache first. load from db if cache miss.\n \"\"\"\n users = [user.to_dict() for user in User.cache.filter()]\n return jsonify(users=users)\n\n\n @app.route('/users/