mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +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",
|
"name": "hydrooj",
|
||||||
"version": "2.32.10",
|
"version": "2.32.11",
|
||||||
"bin": "bin/hydrooj.js",
|
"bin": "bin/hydrooj.js",
|
||||||
"main": "src/loader",
|
"main": "src/loader",
|
||||||
"module": "src/loader",
|
"module": "src/loader",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Collection } from 'mongodb';
|
import { Collection } from 'mongodb';
|
||||||
import LRU from 'lru-cache';
|
import LRU from 'lru-cache';
|
||||||
import { escapeRegExp } from 'lodash';
|
import { escapeRegExp, pick } from 'lodash';
|
||||||
import * as system from './system';
|
import * as system from './system';
|
||||||
import token from './token';
|
import token from './token';
|
||||||
import * as setting from './setting';
|
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) {
|
export function deleteUserCache(udoc: User | Udoc | string | undefined | null, receiver = false) {
|
||||||
if (!udoc) return;
|
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') {
|
if (typeof udoc === 'string') {
|
||||||
for (const key of cache.keys().filter((k) => k.endsWith(`/${udoc}`))) {
|
for (const key of cache.keys().filter((k) => k.endsWith(`/${udoc}`))) {
|
||||||
cache.del(key);
|
cache.del(key);
|
||||||
|
|||||||
Reference in new issue
Block a user