mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 09:36:08 +08:00
core: fix serialize
This commit is contained in:
1 parent
d1facd61d1
commit
d9dc2f2fb6
2 files changed
+8
-3
No files matched your search
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hydrooj",
|
||||
"version": "2.32.10",
|
||||
"version": "2.32.11",
|
||||
"bin": "bin/hydrooj.js",
|
||||
"main": "src/loader",
|
||||
"module": "src/loader",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Collection } from 'mongodb';
|
||||
import LRU from 'lru-cache';
|
||||
import { escapeRegExp } from 'lodash';
|
||||
import { escapeRegExp, pick } from 'lodash';
|
||||
import * as system from './system';
|
||||
import token from './token';
|
||||
import * as setting from './setting';
|
||||
@@ -23,7 +23,12 @@ const cache = new LRU<string, User>({ max: 500, maxAge: 300 * 1000 });
|
||||
|
||||
export function deleteUserCache(udoc: User | Udoc | string | undefined | null, receiver = false) {
|
||||
if (!udoc) return;
|
||||
if (!receiver) bus.broadcast('user/delcache', JSON.stringify(udoc));
|
||||
if (!receiver) {
|
||||
bus.broadcast(
|
||||
'user/delcache',
|
||||
JSON.stringify(typeof udoc === 'string' ? udoc : pick(udoc, ['uname', 'mail', '_id'])),
|
||||
);
|
||||
}
|
||||
if (typeof udoc === 'string') {
|
||||
for (const key of cache.keys().filter((k) => k.endsWith(`/${udoc}`))) {
|
||||
cache.del(key);
|
||||
|
||||
Reference in new issue
Block a user