File tree Expand file tree Collapse file tree 3 files changed +18
-9
lines changed Expand file tree Collapse file tree 3 files changed +18
-9
lines changed Original file line number Diff line number Diff line change @@ -189,6 +189,14 @@ def env_to_bool(env, default):
189
189
'LOCATION' : 'unique-snowflake' ,
190
190
}
191
191
}
192
+ # 使用redis作为缓存
193
+ if os .environ .get ("DJANGO_REDIS_URL" ):
194
+ CACHES = {
195
+ 'default' : {
196
+ 'BACKEND' : 'django.core.cache.backends.redis.RedisCache' ,
197
+ 'LOCATION' : f'redis://{ os .environ .get ("DJANGO_REDIS_URL" )} ' ,
198
+ }
199
+ }
192
200
193
201
SITE_ID = 1
194
202
BAIDU_NOTIFY_URL = os .environ .get ('DJANGO_BAIDU_NOTIFY_URL' ) \
Original file line number Diff line number Diff line change 9
9
import uuid
10
10
from hashlib import sha256
11
11
12
+ import markdown
12
13
import requests
13
14
from django .contrib .sites .models import Site
14
15
from django .core .cache import cache
@@ -33,7 +34,8 @@ def news(*args, **kwargs):
33
34
try :
34
35
view = args [0 ]
35
36
key = view .get_cache_key ()
36
- except BaseException :
37
+ except BaseException as e :
38
+ logger .warning (e )
37
39
key = None
38
40
if not key :
39
41
unique_str = repr ((func , args , kwargs ))
@@ -97,7 +99,6 @@ def get_current_site():
97
99
class CommonMarkdown :
98
100
@staticmethod
99
101
def _convert_markdown (value ):
100
- import markdown
101
102
md = markdown .Markdown (
102
103
extensions = [
103
104
'extra' ,
Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ services:
21
21
volumes :
22
22
- ./bin/datas/mysql/:/var/lib/mysql
23
23
depends_on :
24
- - memcached
24
+ - redis
25
25
container_name : db
26
26
27
27
djangoblog :
@@ -38,10 +38,10 @@ services:
38
38
- DJANGO_MYSQL_PASSWORD=DjAnGoBlOg!2!Q@W#E
39
39
- DJANGO_MYSQL_HOST=db
40
40
- DJANGO_MYSQL_PORT=3306
41
- - DJANGO_MEMCACHED_LOCATION=memcached:11211
41
+ - DJANGO_REDIS_URL=redis:6379
42
42
links :
43
43
- db
44
- - memcached
44
+ - redis
45
45
depends_on :
46
46
- db
47
47
container_name : djangoblog
@@ -58,9 +58,9 @@ services:
58
58
- djangoblog:djangoblog
59
59
container_name : nginx
60
60
61
- memcached :
61
+ redis :
62
62
restart : always
63
- image : memcached :latest
64
- container_name : memcached
63
+ image : redis :latest
64
+ container_name : redis
65
65
ports :
66
- - " 11211:11211 "
66
+ - " 6379:6379 "
You can’t perform that action at this time.
0 commit comments