I was looking at the Laravel docs and I see a cache driver and a redis class. Looking at the cache class it seems like I could just use this to store things in Redis as I just change which driver I am using for caching to the already added Redis driver. However there is also a separate Redis class. Why is there a separate redis class? If the cache class can do the same thing and allow me to also swap which driver I use if ever needed, what reason is there to use the Redis class?
Maybe I am missing something here but I am just confused which one I want to use to store key's and data in redis? I am using Laravel 5.
From the documentation, the Cache class (Facade):
provides a unified API for various caching systems.
One of which is Redis. Another is Memcache. This class serves as a wrapper to abstract functionality to allow you to be technology agnostic. Ideally so you can swap out the underlying caching system without changing application code.
However, by abstracting you can lose functionality specific to a technology. So the Redis class is specific to Redis. If you require Redis specific functionality, you'd need to use this class directly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With