import { Services } from "../lib/Services"; export function Invalidate(keys: string | string[]) { return function ( target: any, propertyKey: string, descriptor: PropertyDescriptor ) { const originalMethod = descriptor.value; descriptor.value = async function (...args: any[]) { const className = target.constructor.name.toLowerCase(); // Metod adı const methodName = propertyKey.toLowerCase(); const cacheKey = ['admin', className]; // Orijinal metodu çağır ve dönen değeri cache'e kaydet const result = await originalMethod.apply(this, args); // Cache'e kaydet (asenkron yapılır, beklenmez) for (let key of keys) { Services.Cache.purge([...cacheKey, key]); Services.Cache.delWithStart([...cacheKey, key]); } console.log('------------------------------Cache deleted.') return result; }; return descriptor; }; } /* const cacheKeys: any[] = target.__cacheKeys || []; console.log("Defined cache keys:", [...cacheKeys].reverse()); const className = target.constructor.name.toLowerCase(); // Metod adı const methodName = propertyKey.toLowerCase(); debugger const cacheKey = ['admin', className, propertyKey]; if (cacheKey.length > 0) { for (let i = 0; i < cacheKeys.length; i++) { const keyIndex = cacheKeys[i]['parameterIndex']; if (args != null && args[keyIndex] != null) { const key = args[keyIndex].toString(); cacheKey.push(key); } } } else if (args.length > 0) { //cacheKey belirtilmemisse tum parametreleri kullan for (let i = 0; i < args.length; i++) { const key = args[i].toString(); cacheKey.push(key); } } */