diff options
| author | Bobby <[email protected]> | 2023-05-28 00:41:28 -0400 |
|---|---|---|
| committer | Bobby <[email protected]> | 2023-05-28 00:41:28 -0400 |
| commit | 1bb0aa7433ec5f9d1bc6252204c8d6e8a682396c (patch) | |
| tree | 38d17386300c1355418d5bed274f65045c8223ca /chat | |
| parent | ac5057a31021cf0c72fa9ad02d238fd0184f508e (diff) | |
| download | thatcomputerscientist-1bb0aa7433ec5f9d1bc6252204c8d6e8a682396c.tar.xz thatcomputerscientist-1bb0aa7433ec5f9d1bc6252204c8d6e8a682396c.zip | |
Post show view count now, Django session uses redis cache
Diffstat (limited to 'chat')
| -rw-r--r-- | chat/chat_cache.py | 3 | ||||
| -rw-r--r-- | chat/consumers.py | 8 | ||||
| -rw-r--r-- | chat/routing.py | 1 | ||||
| -rw-r--r-- | chat/skippy.py | 1 |
4 files changed, 10 insertions, 3 deletions
diff --git a/chat/chat_cache.py b/chat/chat_cache.py index 08cbf178..43354ef7 100644 --- a/chat/chat_cache.py +++ b/chat/chat_cache.py @@ -1,6 +1,7 @@ -import redis import json +import redis + r = redis.Redis(host='localhost', port=6379, db=0) def handle_connect(): diff --git a/chat/consumers.py b/chat/consumers.py index 0b3017c4..da81449c 100644 --- a/chat/consumers.py +++ b/chat/consumers.py @@ -1,9 +1,13 @@ import json -from channels.generic.websocket import WebsocketConsumer + from asgiref.sync import async_to_sync -from .chat_cache import handle_connect, handle_disconnect, handle_alone_user, discard_user_messages +from channels.generic.websocket import WebsocketConsumer + +from .chat_cache import (discard_user_messages, handle_alone_user, + handle_connect, handle_disconnect) from .skippy import invokeMFSkippy + class ChatConsumer(WebsocketConsumer): def connect(self): self.room_group_name = "chat" diff --git a/chat/routing.py b/chat/routing.py index 69101be1..fe6b4681 100644 --- a/chat/routing.py +++ b/chat/routing.py @@ -1,4 +1,5 @@ from django.urls import re_path + from . import consumers websocket_urlpatterns = [ diff --git a/chat/skippy.py b/chat/skippy.py index bf6ab6ac..6fa3aaa1 100644 --- a/chat/skippy.py +++ b/chat/skippy.py @@ -1,5 +1,6 @@ from .chat_cache import get_user_messages, save_user_messages + def invokeMFSkippy(message, identifier): save_user_messages(user_identifier=identifier, message={'content': message, 'role': 'user'}) user_messages = get_user_messages(user_identifier=identifier) |
