> For the complete documentation index, see [llms.txt](https://krypt0nn.gitbook.io/empathize/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://krypt0nn.gitbook.io/empathize/api/meta-classes/cache.md).

# Cache

## Record

| Name    | Type    | Description              |
| ------- | ------- | ------------------------ |
| expired | boolean | Was cache expired or not |
| value   | any     | Cache value              |

## Cache class

### Cache.file

Path to the file where the cache should be stored

### Cache.get(name)

```typescript
import { Cache, promisify } from '@empathize/framework';

promisify(async () => {
    let record = await Cache.get('not_existing_record');
    
    // Record doesn't exist
    console.log(record === null ? 'Record doesn\'t exist' : 'Record exist');
    
    record = await Cache.get('existing_record');
    
    // Record exists
    console.log(record === null ? 'Record doesn\'t exist' : 'Record exists');
});
```

### Cache.set(name, value, ttl)

```typescript
import { Cache } from '@empathize/framework';

// Will be cached forever
Cache.set('record_1', 'Hello, World!');

// Will be cached for 24 hours
Cache.set('record_2', 'Hello, World!', 24 * 3600);
```
