Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

hunterhawley's avatar

Best Storage Method

Hey y'all,

Quick question here: I'm working on the proposed solution to the following question (https://laracasts.com/discuss/channels/laravel/i-dropped-my-query-count-by-29980-but-page-still-takes-30-seconds-to-load) but could use a little guidance.

In this case, I am trying to cache a bunch of calculated basketball stats (Assists, Shooting percentage, etc.). For simplicity sake, assume we are just caching season-wide stats (I'll do other calculations but they will follow this same procedure).

Which storage type should I use for this? I basically need a table like this (https://ibb.co/M7cZ2vt) to be re-creatable from whatever I do. I don't really want to do JSON (personal preference) but if there is a case for why that is best, I'm up for it.

Should I maybe store as an array? Let me know what you think.

0 likes
3 replies
bobbybouwmann's avatar

The format you store it in doesn't really matter since it's in your cache anyway. Use whatever you prefer.

For me personally I like to store DTO's or ValueObjects. This way you know exactly what kind of object you get back from the cache. If you store just an array you also have to validate if certain keys exists and so on.

A good way of caching in this case might be russian doll caching. This works like the russian dolls that you can stash in each other. Laracasts has a series on that as well: https://laracasts.com/series/russian-doll-caching-in-laravel

hunterhawley's avatar

I'll look into this. Thanks! This is my first app I'm developing and Laracasts always comes through to help!

Please or to participate in this conversation.