Back

image
๐—›๐—ฒ๐˜†! ๐Ÿ˜€ ๐—ง๐—ผ๐—ฑ๐—ฎ๐˜† ๐—œ'๐—บ ๐—ฝ๐—ผ๐˜€๐˜๐—ถ๐—ป๐—ด ๐—บ๐˜† ๐Ÿญ๐˜€๐˜ ๐—ฐ๐—ผ๐—ฑ๐—ฒ ๐˜๐—ถ๐—ฝ ๐—ณ๐—ผ๐—ฟ ๐—Ÿ๐—ฎ๐—ฟ๐—ฎ๐˜ƒ๐—ฒ๐—น๐—ถ๐—ฎ๐—ป๐˜€ โค๏ธ

I hope that you'll enjoy it ๐Ÿฅณ & don't forget to follow me for more tips & tricks in the future ๐Ÿ˜‰

Look how easy it is to make file-based cache's in Laravel.

๐Ÿญ. ๐—ช๐—ต๐—ฎ๐˜ ๐—ถ๐˜€ ๐—›๐—ฎ๐—ฝ๐—ฝ๐—ฒ๐—ป๐—ถ๐—ป๐—ด?

๐—–๐—ฎ๐—ฐ๐—ต๐—ฒ::๐—ฟ๐—ฒ๐—บ๐—ฒ๐—บ๐—ฏ๐—ฒ๐—ฟ(): Method is used to store and retrieve data efficiently in hashtag#Laravel.

๐—ฐ๐—ฎ๐—ฐ๐—ต๐—ฒ๐—ก๐—ฎ๐—บ๐—ฒ: If a cache with this key "cacheName" exists, the cached data is returned. If not, the callback function runs, fetches all users, stores it in the cache, and returns it.

๐—ป๐—ผ๐˜„()->๐—ฎ๐—ฑ๐—ฑ๐——๐—ฎ๐˜†(): sets the cache expiration to 24 hours from the current time.

๐Ÿฏ. ๐—จ๐˜€๐—ฒ ๐—–๐—ฎ๐˜€๐—ฒ

This approach helps optimize database queries by reducing repetitive calls, improving your App's speed & performance.

2 โ€ข โ€ข

100

โ€ข

0 / 1000

Hey! It is not necessarily a file-based cache. It all depends on your config, but in Laravel, cache might be DB-based, file-based and Redis/Memcached based

1 โ€ข โ€ข

44

โ€ข

Yeah! I know it necessarily a file-based case but as you know that "file-based" is built-in without any configuration & I'm talking about that.

โ€ข โ€ข

3

โ€ข

What is best way to handle cache with database changes

1 โ€ข โ€ข

120

โ€ข