|
|
@@ -20,10 +20,13 @@ import { LatestVideosCacheBuilder } from '@box/core/cache/video/latest/latest-vi
|
|
|
import { RecommendedVideosCacheBuilder } from '@box/core/cache/video/recommended/recommended-videos-cache.builder';
|
|
|
|
|
|
const GROUP_PATTERNS: Record<RedisInspectorGroupCode, string> = {
|
|
|
+ [RedisInspectorGroupCode.CHANNEL]: 'box:app:channel*',
|
|
|
+ [RedisInspectorGroupCode.CATEGORY]: 'box:app:category*',
|
|
|
+ [RedisInspectorGroupCode.TAG]: 'box:app:tag*',
|
|
|
[RedisInspectorGroupCode.VIDEO]: 'box:app:video*',
|
|
|
- [RedisInspectorGroupCode.ADS]: 'box:app:ads*',
|
|
|
- [RedisInspectorGroupCode.MOVIE]: 'box:app:movie*',
|
|
|
+ [RedisInspectorGroupCode.ADS]: 'box:app:adpool*',
|
|
|
};
|
|
|
+const MAX_JSON_PARSE_BYTES = 2 * 1024 * 1024;
|
|
|
|
|
|
@Injectable()
|
|
|
export class RedisInspectorService {
|
|
|
@@ -141,17 +144,34 @@ export class RedisInspectorService {
|
|
|
const byteLen = await this.redisService.strLen(key);
|
|
|
const rawValue = (await this.redisService.get(key)) ?? '';
|
|
|
const { text, truncated } = this.prepareStringPreview(rawValue);
|
|
|
+ const meta: Record<string, any> = { byteLen };
|
|
|
const preview: Record<string, any> = {
|
|
|
format: 'text',
|
|
|
data: text,
|
|
|
};
|
|
|
|
|
|
- if (!truncated && text) {
|
|
|
- const parsed = this.tryParseJson(text);
|
|
|
- if (parsed !== undefined) {
|
|
|
- preview.format = 'json';
|
|
|
- preview.data = parsed;
|
|
|
+ const canParseJson = byteLen <= MAX_JSON_PARSE_BYTES;
|
|
|
+ const candidate = canParseJson ? this.tryParseJson(rawValue) : undefined;
|
|
|
+
|
|
|
+ if (candidate !== undefined && Array.isArray(candidate)) {
|
|
|
+ meta.itemCount = candidate.length;
|
|
|
+ preview.format = 'json';
|
|
|
+ preview.data = candidate.slice(0, 5);
|
|
|
+ if (candidate.length > 5) {
|
|
|
+ preview.truncated = true;
|
|
|
}
|
|
|
+ return {
|
|
|
+ key,
|
|
|
+ type: 'string',
|
|
|
+ ttlSec,
|
|
|
+ meta,
|
|
|
+ preview,
|
|
|
+ };
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!truncated && candidate !== undefined) {
|
|
|
+ preview.format = 'json';
|
|
|
+ preview.data = candidate;
|
|
|
}
|
|
|
|
|
|
if (truncated) {
|
|
|
@@ -162,7 +182,7 @@ export class RedisInspectorService {
|
|
|
key,
|
|
|
type: 'string',
|
|
|
ttlSec,
|
|
|
- meta: { byteLen },
|
|
|
+ meta,
|
|
|
preview,
|
|
|
};
|
|
|
}
|