๐Ÿ”ฅ Weekly thread #26 of 2022

๐Ÿ”ฅ This week's code tips for Laravel developers

A weekly thread ๐Ÿงต

Use database partitions to delete large chunks of data efficiently

4

๐Ÿ”ฅ Use database partitions to delete large chunks of data efficiently

Use database partitions to delete large chunks of data efficiently

โšก Database Tip

Some applications want to periodically delete old historic data (or have to because of regulations). Deleting billions of rows is a very slow task that could take several minutes and may take your application down. Use partitions for efficient deleting!

Encrypted casts can use unique model-derived keys

3

๐Ÿ”ฅ Encrypted casts can use unique model-derived keys

Encrypted casts can use unique model-derived keys

๐Ÿ”ฅ #Laravel Tip:

The default encryption cast for Eloquent models uses the app key, making rotation difficult and allowing anyone with key to decrypt all the DB. To address this, consider creating a custom cast that uses the model to create its own unique key.

Laravel's RateLimiter can be used to throttle ANY parts of your code

2

๐Ÿ”ฅ Laravel's RateLimiter can be used to throttle ANY parts of your code

Laravel's RateLimiter can be used to throttle ANY parts of your code

๐Ÿ”ฅ #Laravel Tip: Rate-limiting is not only for throttling entire requests. You can also use it to throttle methods or parts of your code, which can be really useful when you need to protect things against spikes e.g. the DB.

We're writing a book, you can get it for free here.