تماشای این درس نیاز به اشتراک حرفه‌ای دارد.

Cache Use Cases0:00

There are multiple use cases for using a cache in our Laravel applications. For instance, some operations performed by our application could be CPU-intensive or take several seconds to complete. If we cache the results of those operations for a time, we can retrieve it quickly on subsequent requests, which enhances our application's response time. We may also use a cache to store session data instead of storing it in the database, which is much faster. There is also the use case of atomic locks. They are more efficient and reliable when using a proper cache driver. By default, Laravel configures a DynamoDB table to act as our cache driver.

Configure Vapor Cache Driver1:55

Now let's wait for the cache to provision. And while we wait, it's worth to mention that ElastiCache instances can only be created inside private subnets. That means Vapor will have to provision an add gateway and attach it to the network in order for the cache to be created successfully. And once the cache is ready, we go to our code editor, modify the Vapor.yaml file and add cache Laracasts. And then we deploy. Behind the scenes, Vapor will update the environment variables to change our application cache driver to Redis and configure it to communicate with the Redis cluster we just created.

Behind the scenes, Vapor will update the environment variables to change our application cache driver to Redis and configure it to communicate with the Redis cluster we just created. Now we can use the full might of Redis in our serverless Laravel applications.

AWS ElasticacheVapor Cache Configuration

دوست دارید گاهی خبرهای Laracasts را ایمیل کنیم؟