Skip to content

Commit 1b26a91

Browse files
committed
Update to pymemcache 1.2.3
1 parent 07435cb commit 1b26a91

File tree

5 files changed

+10
-24
lines changed

5 files changed

+10
-24
lines changed

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ Put kwargs for pymemcache to `PYMEMCACHE` in your Flask configuration.
3131
'connect_timeout': 1.0,
3232
'timeout': 0.5,
3333
'no_delay': True,
34+
'key_prefix': b'myapp-',
3435
}
3536

3637
You can use different config key with `conf_key` keyword::
@@ -44,7 +45,6 @@ You can use different config key with `conf_key` keyword::
4445
In addition to normal pymemcache kwargs, Flask-PyMemcache provides following
4546
configuration options.
4647

47-
* `prefix` -- Add prefix to all key. (Default: b'')
4848
* `close_on_teardown` -- Close connection to memcached when app teardown.
4949

5050
Use

flask_pymemcache.py

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
'connect_timeout': 1.0,
3131
'timeout': 0.5,
3232
'no_delay': True,
33+
'key_prefix': b'myapp-',
3334
}
3435
3536
You can use different config key with `conf_key` keyword::
@@ -43,7 +44,6 @@
4344
In addition to normal pymemcache kwargs, Flask-PyMemcache provides following
4445
configuration options.
4546
46-
* `prefix` -- Add prefix to all key. (Default: b'')
4747
* `close_on_teardown` -- Close connection to memcached when app teardown.
4848
4949
Use
@@ -59,18 +59,6 @@
5959
import pymemcache.client
6060

6161

62-
class FlaskMemcacheClient(pymemcache.client.Client):
63-
"""PyMemcache client supporting prefix"""
64-
def __init__(self, prefix=b'', **kwargs):
65-
if not isinstance(prefix, bytes):
66-
prefix = prefix.encode('ascii')
67-
self.prefix = prefix
68-
super(FlaskMemcacheClient, self).__init__(**kwargs)
69-
70-
def check_key(self, key):
71-
return super(FlaskMemcacheClient, self).check_key(self.prefix + key)
72-
73-
7462
class FlaskPyMemcache(object):
7563

7664
def __init__(self, app=None, conf_key=None):
@@ -94,8 +82,9 @@ def init_app(self, app, conf_key=None):
9482
raise TypeError("Flask-PyMemcache conf should be dict")
9583

9684
close_on_teardown = conf.pop('close_on_teardown', False)
97-
client = FlaskMemcacheClient(**conf)
98-
app.extensions[self] = client
85+
client = pymemcache.client.Client(**conf)
86+
app.extensions.setdefault('pymemcache', {})
87+
app.extensions['pymemcache'][self] = client
9988

10089
if close_on_teardown:
10190
@app.teardown_appcontext
@@ -107,4 +96,4 @@ def client(self):
10796
"""
10897
:rtype: pymemcache.client.Client
10998
"""
110-
return flask.current_app.extensions[self]
99+
return flask.current_app.extensions['pymemcache'][self]

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111

1212
setup(
1313
name="Flask-PyMemcache",
14-
version='0.0.3',
14+
version='0.0.4',
1515
py_modules=['flask_pymemcache'],
1616
author='INADA Naoki',
1717
author_email='songofacandy at gmail dot com',
1818
url='https://github.com/KLab/Flask-PyMemcache',
1919
description="pymemcache integration for Flask",
2020
long_description=readme,
21-
install_requires=["Flask", "pymemcache>=1.2.2", "six"],
21+
install_requires=["Flask", "pymemcache>=1.2.3", "six"],
2222
)

test_flask_pymemcache.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def test_simple():
1212
app = flask.Flask(__name__)
1313
app.config['PYMEMCACHE'] = {
1414
'server': ('localhost', 11211),
15-
'prefix': b'px'}
15+
'key_prefix': b'px'}
1616
memcache.init_app(app)
1717

1818
with app.app_context():

tox.ini

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,5 @@
22
envlist = py27,py33
33

44
[testenv]
5-
install_command = pip install {opts} {packages}
6-
deps =
7-
pymemcache
8-
pytest
5+
deps = pytest
96
commands = py.test

0 commit comments

Comments
 (0)