ram64
Version:
Multi-threaded 64bit memory cache database inspired by redis-like features
16 lines (12 loc) • 555 B
text/typescript
import { CommandFn, CommandOptions } from '../../commands';
import { CacheObject } from '../../types';
import { fn as getWithOptions } from './getWithOptions';
export const fn: CommandFn = (opts: CommandOptions): boolean => {
const obj: CacheObject = getWithOptions(opts);
if (!obj) return false;
if (typeof opts.args !== 'object') throw new Error('Invalid options');
// mutate is the most performant option
obj.expAt = opts.args.expAt ?? void 0;
obj.staleAt = opts.args.staleAt ?? void 0;
return true;
}