Search code examples
javaspring-booth2db

@Cacheable with in memory database?


Is it relevant to use @Cacheable with in memory database ?
I am using h2 in memory database and just wondering that use of @Cacheable can improve the performance of application. My application will have frequent get calls for the static data from database


Solution

  • Generally - yes, it is.

    In your case - I don't know, you didn't give enough info.

    If you are doing a lot of small queries just to extract data (select by primary key etc.), then it's not worth it. Wouldn't be worth it even with regular database, unless you have terrible connection or something.

    If you are doing huge queries, which take lot of time to find the data - then yes, definitely, same as with regular database.