Sync-in · Sovereign platform for file storage, sharing, synchronization, and collaboration.
TypeScript cloud-alternativecollaborationcollaborative-editingdropboxfile-serverfile-sharingfile-storagefile-syncfull-text-searchhomelabnextcloudon-premiseopen-sourceprivacy-firstprivate-cloudrealtimesecureself-hostedstorage-serverwebdav
feat(backend:infrastructure): allow null or undefined args in cache key slug generation
johaven9d661ea4ba4d
diff --git a/backend/src/common/shared.ts b/backend/src/common/shared.tsindex 07897fc9..667b37ac 100644--- a/backend/src/common/shared.ts+++ b/backend/src/common/shared.ts@@ -43,6 +43,10 @@ export function createSlug(input: string, replaceCount = false): string {return r}+export function createCacheKeySlug(args: unknown[]) {+ return createSlug(args.map((arg) => (arg == null ? 'null' : String(arg))).join(' '))+}+export function createLightSlug(input: string) {return input.toLowerCase()diff --git a/backend/src/infrastructure/cache/adapters/mysql-cache.adapter.ts b/backend/src/infrastructure/cache/adapters/mysql-cache.adapter.tsindex 98b13972..52e48463 100644--- a/backend/src/infrastructure/cache/adapters/mysql-cache.adapter.ts+++ b/backend/src/infrastructure/cache/adapters/mysql-cache.adapter.ts@@ -3,7 +3,7 @@ import { SchedulerRegistry } from '@nestjs/schedule'import { CronJob } from 'cron'import { and, between, eq, exists, inArray, like, notBetween, SQL } from 'drizzle-orm'import cluster from 'node:cluster'-import { createSlug, currentTimeStamp } from '../../../common/shared'+import { createCacheKeySlug, currentTimeStamp } from '../../../common/shared'import { configuration } from '../../../configuration/config.environment'import { DB_TOKEN_PROVIDER } from '../../database/constants'import { DBSchema } from '../../database/interfaces/database.interface'@@ -125,7 +125,7 @@ export class MysqlCacheAdapter implements Cache {}genSlugKey(...args: any[]): string {- return createSlug(args.join(' '))+ return createCacheKeySlug(args)}private readonly whereNotExpired: () => SQL = () => notBetween(cache.expiration, 0, currentTimeStamp())diff --git a/backend/src/infrastructure/cache/adapters/redis-cache.adapter.ts b/backend/src/infrastructure/cache/adapters/redis-cache.adapter.tsindex 3a3b39fa..8af12d3d 100644--- a/backend/src/infrastructure/cache/adapters/redis-cache.adapter.ts+++ b/backend/src/infrastructure/cache/adapters/redis-cache.adapter.ts@@ -1,7 +1,7 @@import { Injectable, Logger } from '@nestjs/common'import { RedisClientOptions } from '@redis/client'import { createClient, RedisClientType } from 'redis'-import { createSlug } from '../../../common/shared'+import { createCacheKeySlug } from '../../../common/shared'import { configuration } from '../../../configuration/config.environment'import { Cache } from '../services/cache.service'@@ -71,7 +71,7 @@ export class RedisCacheAdapter implements Cache {}genSlugKey(...args: any[]): string {- return createSlug(args.join(' '))+ return createCacheKeySlug(args)}private readonly reconnectStrategy = (attempts: number): number => {