-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
51 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
language: python | ||
|
||
notifications: | ||
email: false | ||
|
||
python: | ||
- "3.5" | ||
- "3.6" | ||
|
||
script: python -m unittest discover -s tests/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,6 @@ | ||
from .cache_setting import CacheSetting | ||
from .cache_setting import CacheSetting, Settings | ||
from .decorator import cached | ||
from .memcached_cache import MemcachedCache | ||
from .memory_cache import MemoryCache | ||
from .redis_cache import RedisCache | ||
from .serializer import JsonSerializer, PickleSerializer, StrSerializer | ||
|
||
|
||
class Settings: | ||
"""Global Settings""" | ||
cache = { | ||
'cache_class': MemoryCache, | ||
'cache_config': {}, | ||
'serializer': None, | ||
'ttl': None | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
#!/usr/bin/env python | ||
import abc | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
#!/usr/bin/env python | ||
from functools import wraps | ||
|
||
from colorama import Fore | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
#!/usr/bin/env python | ||
from pymemcache.client.base import Client | ||
|
||
from expire.base_cache import BaseCache | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
#!/usr/bin/env python | ||
import time | ||
|
||
from expire.serializer import PickleSerializer | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
#!/usr/bin/env python | ||
import redis | ||
|
||
from expire.base_cache import BaseCache | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
#!/usr/bin/env python | ||
|
||
from expire.base_cache import BaseSerializer | ||
|
||
try: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,36 @@ | ||
#!/usr/bin/env python | ||
import unittest | ||
|
||
from expire import CacheSetting, JsonSerializer, MemoryCache, PickleSerializer, Settings, cached | ||
|
||
|
||
def test_memory_cache(): | ||
memory_cache = MemoryCache() | ||
memory_cache.set('name', 'expire') | ||
cache_ins = CacheSetting() | ||
assert cache_ins.get('name') == 'expire' | ||
class TestExpire(unittest.TestCase): | ||
def test_memory_cache(self): | ||
memory_cache = MemoryCache() | ||
memory_cache.set('name', 'expire') | ||
cache_ins = CacheSetting() | ||
assert cache_ins.get('name') == 'expire' | ||
|
||
def test_cached(self): | ||
cache_ins = CacheSetting(Settings) | ||
|
||
def test_cached(): | ||
cache_ins = CacheSetting(Settings) | ||
@cached(**Settings.cache) | ||
def hello_cache(name, **kwargs): | ||
return 'hello expire' | ||
|
||
@cached(**Settings.cache) | ||
def hello_cache(name, **kwargs): | ||
return 'hello expire' | ||
name = 'expire' | ||
hello_cache(name=name, dynamic_key=name) | ||
assert cache_ins.get(name) == 'hello expire' | ||
|
||
name = 'expire' | ||
hello_cache(name=name, dynamic_key=name) | ||
assert cache_ins.get(name) == 'hello expire' | ||
def test_serializer(self): | ||
test = { | ||
'name': 'expire', | ||
'url': 'https://github.com/howie6879/expire' | ||
} | ||
serializer_ins = JsonSerializer() | ||
pickle_ins = PickleSerializer() | ||
assert pickle_ins.loads(pickle_ins.dumps(test)) == test | ||
assert serializer_ins.loads(serializer_ins.dumps(test)) == test | ||
|
||
|
||
def test_serializer(): | ||
test = { | ||
'name': 'expire', | ||
'url': 'https://github.com/howie6879/expire' | ||
} | ||
serializer_ins = JsonSerializer() | ||
pickle_ins = PickleSerializer() | ||
assert pickle_ins.loads(pickle_ins.dumps(test)) == test | ||
assert serializer_ins.loads(serializer_ins.dumps(test)) == test | ||
if __name__ == '__main__': | ||
unittest.main() |