Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change deprecated name import flask.ext.cache to flask_cache #149

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Flask-Cache
================

.. module:: flask.ext.cache
.. module:: flask_cache

Installation
------------
Expand All @@ -20,8 +20,14 @@ Set Up
Cache is managed through a ``Cache`` instance::

from flask import Flask


# if Flask version < 0.11.0
from flask.ext.cache import Cache

# if Flask version >= 0.11.0
from flask_cache import Cache

app = Flask(__name__)
# Check Configuring Flask-Cache section for more details
cache = Cache(app,config={'CACHE_TYPE': 'simple'})
Expand Down Expand Up @@ -167,7 +173,15 @@ Set timeout to "del" to delete cached value::
If keys are provided, you may easily generate the template fragment key and
delete it from outside of the template context::



# if Flask version < 0.11.0
from flask.ext.cache import make_template_fragment_key

# if Flask version >= 0.11.0
from flask_cache import make_template_fragment_key


key = make_template_fragment_key("key1", vary_on=["key2", "key3"])
cache.delete(key)

Expand All @@ -192,8 +206,15 @@ Here's an example script to empty your application's cache:

.. code-block:: python


# if Flask version < 0.11.0
from flask.ext.cache import Cache

# if Flask version >= 0.11.0
from flask_cache import Cache



from yourapp import app, your_cache_config

cache = Cache()
Expand Down
11 changes: 8 additions & 3 deletions examples/hello.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
import random
from datetime import datetime

from flask import Flask, jsonify
from flask.ext.cache import Cache

from flask import Flask,__version__, jsonify

if tuple( map(int, __version__.split("."))) >= (0,11,0):
from flask_cache import Cache
else:
from flask.ext.cache import Cache


app = Flask(__name__)
app.config.from_pyfile('hello.cfg')
cache = Cache(app)

#: This is an example of a cached view
#: This is an example of a cached view
@app.route('/api/now')
@cache.cached(50)
def current_time():
Expand Down
2 changes: 1 addition & 1 deletion flask_cache/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
"""
flask.ext.cache
flask_cache
~~~~~~~~~~~~~~

Adds cache support to your application.
Expand Down
8 changes: 7 additions & 1 deletion flask_cache/jinja2ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,13 @@

from jinja2 import nodes
from jinja2.ext import Extension
from flask.ext.cache import make_template_fragment_key
from flask import __version__

if tuple( map(int, __version__.split("."))) >= (0,11,0):
from flask_cache import make_template_fragment_key
else:
from flask.ext.cache import make_template_fragment_key


JINJA_CACHE_ATTR_NAME = '_template_fragment_cache'

Expand Down
10 changes: 8 additions & 2 deletions test_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,14 @@
import random
import string

from flask import Flask, render_template, render_template_string
from flask.ext.cache import Cache, function_namespace, make_template_fragment_key

from flask import Flask,__version__, render_template, render_template_string

if tuple( map(int, __version__.split("."))) >= (0,11,0):
from flask_cache import Cache, function_namespace, make_template_fragment_key
else:
from flask.ext.cache import Cache, function_namespace, make_template_fragment_key


if sys.version_info < (2,7):
import unittest2 as unittest
Expand Down