Skip to content

Commit bf55d28

Browse files
committed
opt store form cache
1 parent d580ad3 commit bf55d28

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

dtable_events/tasks/dtable_upload_link_handler.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
from dtable_events.app.event_redis import RedisClient, redis_cache
1414
from dtable_events.db import init_db_session_class
15-
from dtable_events.utils import uuid_str_to_36_chars
15+
from dtable_events.utils import uuid_str_to_36_chars, uuid_str_to_32_chars
1616

1717
logger = logging.getLogger(__name__)
1818

@@ -29,7 +29,7 @@ def get_cache_key(self, hour):
2929
return f'public_form_upload_link:{hour}'
3030

3131
def handle_upload_link(self, event_data):
32-
dtable_uuid = event_data.get('dtable_uuid')
32+
dtable_uuid = uuid_str_to_32_chars(event_data.get('dtable_uuid'))
3333
repo_id = event_data.get('repo_id')
3434
parent_dir = event_data.get('parent_dir') or ''
3535
if 'public/forms' not in parent_dir:
@@ -43,7 +43,13 @@ def handle_upload_link(self, event_data):
4343
logger.warning('key: %s cache invalid', cache_key)
4444
dtable_uuids = [(dtable_uuid, repo_id)]
4545
else:
46-
dtable_uuids.append((dtable_uuid, repo_id))
46+
flag = True
47+
for tmp_dtable_uuid, _ in dtable_uuids:
48+
if dtable_uuid == tmp_dtable_uuid:
49+
flag = False
50+
break
51+
if flag:
52+
dtable_uuids.append((dtable_uuid, repo_id))
4753
else:
4854
dtable_uuids = [(dtable_uuid, repo_id)]
4955
redis_cache.set(cache_key, json.dumps(dtable_uuids), self.cache_timeout)

0 commit comments

Comments
 (0)