typeorm icon indicating copy to clipboard operation
typeorm copied to clipboard

Is it possible to cache specific entity ?

Open roeehershko opened this issue 8 years ago • 3 comments

Issue type:

[*] question [ ] bug report [ ] feature request [ ] documentation issue

Database system/driver:

[ ] cordova [ ] mongodb [ ] mssql [*] mysql / mariadb [ ] oracle [ ] postgres [ ] sqlite [ ] sqljs [ ] websql

TypeORM version:

[*] latest [ ] @next [ ] 0.x.x (or put your version here)

Steps to reproduce or a small repository showing the problem:

reading this doc: https://github.com/typeorm/typeorm/blob/master/docs/caching.md

i understand that you can cache a query via { cache: true } and globally cache via the options

{
    type: "mysql",
    host: "localhost",
    username: "test",
    ...
    cache: {
        duration: 30000 // 30 seconds
    }
}

but is it possible to cache globally a specific entity? for example, i have customer_statuses entity which i wanna cache all the time in all the queries without manually putting { cache: true }, is such a think possible?

roeehershko avatar Apr 12 '18 12:04 roeehershko

you can cache per-select using cache flag inside find options or using .cache method of QueryBuilder.

pleerock avatar Apr 12 '18 13:04 pleerock

Let me know if you still have questions.

pleerock avatar Apr 19 '18 13:04 pleerock

Can Typeorm cache entity when get from database and store till other query call that Entity

raidichu avatar Mar 19 '21 04:03 raidichu