Utils for testing with/without cache
Project description
switchcache
====
Test utils for testing with memcache
## with_cache/no_cache decorators
```python
from switchcache import init, with_cache, no_cache
class Configure:
HOSTS = ['127.0.0.1:11211']
CACHE = {
'foo': 'bar',
'fuga': 'hoge'
}
init(Configure)
@with_cache
def test_with_cache():
<Cache enabled in this function>
@no_cache
def test_no_cache():
<Cache disabled in this function>
```
## "with" clause
```python
from switchcache import cache
def test():
with cache:
<Cache enabled inside "with">
<Cache disabled outside "with">
```
## twice/times decorators
```python
from switchcache import twice, times
@twice
def test_twice(s):
return s
>>> test_twice('foo')
['foo', 'foo']
@times(5)
def test_5_times(s):
return s
>>> test_5_times('bar')
['bar', 'bar', 'bar', 'bar', 'bar']
```
## Note
Make sure HOSTS point to a your testing environment.
Your current caches on memcache will be flushed & overrided.
====
Test utils for testing with memcache
## with_cache/no_cache decorators
```python
from switchcache import init, with_cache, no_cache
class Configure:
HOSTS = ['127.0.0.1:11211']
CACHE = {
'foo': 'bar',
'fuga': 'hoge'
}
init(Configure)
@with_cache
def test_with_cache():
<Cache enabled in this function>
@no_cache
def test_no_cache():
<Cache disabled in this function>
```
## "with" clause
```python
from switchcache import cache
def test():
with cache:
<Cache enabled inside "with">
<Cache disabled outside "with">
```
## twice/times decorators
```python
from switchcache import twice, times
@twice
def test_twice(s):
return s
>>> test_twice('foo')
['foo', 'foo']
@times(5)
def test_5_times(s):
return s
>>> test_5_times('bar')
['bar', 'bar', 'bar', 'bar', 'bar']
```
## Note
Make sure HOSTS point to a your testing environment.
Your current caches on memcache will be flushed & overrided.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
switchcache-0.1.1.tar.gz
(3.2 kB
view details)
Built Distributions
switchcache-0.1.1-py2.7.egg
(5.9 kB
view details)
File details
Details for the file switchcache-0.1.1.tar.gz
.
File metadata
- Download URL: switchcache-0.1.1.tar.gz
- Upload date:
- Size: 3.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 959d20702610d362361eb212353b9173b8065ef03189cebf569b6240e5ab1ad3 |
|
MD5 | 77d1b6f417f45b06611c4009bfd38234 |
|
BLAKE2b-256 | 5ed9da38ca995834481aa5e80e63577ebd38d38d1c0e13ee45b8adba8afa714b |
File details
Details for the file switchcache-0.1.1.macosx-10.9-intel.tar.gz
.
File metadata
- Download URL: switchcache-0.1.1.macosx-10.9-intel.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cc65f08d1bd0823f8b09cb1097f10867ca5b927863a5f6c95f07c21c899a5701 |
|
MD5 | e64d4efee63d5b110416929ebd83fe4b |
|
BLAKE2b-256 | 44962e3b6041677cae55468e165802a14c33b1012fa3fedf5fd8a5b8cec4420f |
File details
Details for the file switchcache-0.1.1-py2.7.egg
.
File metadata
- Download URL: switchcache-0.1.1-py2.7.egg
- Upload date:
- Size: 5.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 62a116b521bdc830593c072940052827dbedab9f8542d5cb2b824373c54cee1f |
|
MD5 | 35d419cb20cf6023478e685daa6bd929 |
|
BLAKE2b-256 | 0da8154a54f9da46c812d0103656be0b2d41509327357f2af5b84f34e917e4fb |