Home > Mobile >  What are drivers in laravel? Eg cache driver
What are drivers in laravel? Eg cache driver

Time:06-11

i am reading the laravel documentation but i didnt get about the term about drivers. For example i found that laravel cache is using following drivers

  • array
  • redis
  • file
  • apc

so my question is what are drivers? What do we mean by them in case of laravel and why laravel use drivers? Need simple concept so i can carry on

CodePudding user response:

A driver is an implementation of an interface. For the Caching system, the array driver caches everything in an in-memory array per request. Meaning at the start of each request the cache will be empty.

The file driver implements the caching interface and persists the cache in a file which you can specify in your config.

The redis driver implements the cache interface which persists the cache in a redis database.

etc.

A "cache driver" in Laravel, is a class that implements the contract (interface) Illuminate\Contracts\Cache\Store.

The app does not care what happens beyond calling get or put for example. It is up to the driver to determine what "getting" and "putting" actually means.

  • Related