> For the complete documentation index, see [llms.txt](https://query.docs.doyto.win/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://query.docs.doyto.win/web/cache.md).

# Cache

There are two ways to enable caching for target entities.

## Configuration

Specify their class names using the `doyto.query.caches` property in the `application.yaml` file:

```yaml
doyto:
  query:
    caches: UserEntity, MenuEntity
```

## Programmatic

Override method `getCacheName()` in `AbstractDynamicService`:

```java
public class UserService extends AbstractCrudService<UserEntity, Integer, UserQuery> {
    @Override
    protected String getCacheName() {
        return "module:user"; // return any string except UserEntity 
    }
}
```
