mirror of
https://github.com/donnemartin/system-design-primer
synced 2026-01-03 07:48:02 +00:00
Simplify online chat solution
This commit is contained in:
@@ -69,8 +69,6 @@
|
||||
"\n",
|
||||
"class UserService(object):\n",
|
||||
"\n",
|
||||
" __metaclass__ = Singleton\n",
|
||||
"\n",
|
||||
" def __init__(self):\n",
|
||||
" self.users_by_id = {} # key: user id, value: User\n",
|
||||
"\n",
|
||||
@@ -145,16 +143,7 @@
|
||||
" UNREAD = 0\n",
|
||||
" READ = 1\n",
|
||||
" ACCEPTED = 2\n",
|
||||
" REJECTED = 3\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"class Singleton(type):\n",
|
||||
"\n",
|
||||
" _instances = {}\n",
|
||||
" def __call__(cls, *args, **kwargs):\n",
|
||||
" if cls not in cls._instances:\n",
|
||||
" cls._instances[cls] = super(Singleton, cls).__call__(*args, **kwargs)\n",
|
||||
" return cls._instances[cls]"
|
||||
" REJECTED = 3"
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user