DEV Community

Cover image for How to Create Own Cache driver and Learn Cache drivers from Laravel
Rohit Urane
Rohit Urane

Posted on

1 1

How to Create Own Cache driver and Learn Cache drivers from Laravel

Laravel provides an expressive, unified API for various caching backends. We stored all Cache information in the config/cache.php file of your project. They configure Laravel to use a file cache driver to keep the serialized cached objects in the filesystem.

Driver Prerequisites:-

Database:

You are going with a database cache driver. You will need to create a table that contains cache items.

Schema::create('cache', function ($table) {
    $table->string('key')->unique();
    $table->text('value');
    $table->integer('expiration');
});
Enter fullscreen mode Exit fullscreen mode

Run the artisan command php artisan cache:table. It will generate a migration with the proper schema.

Memcached:

For Memcached driver requires Memcached PECL package. You may list all the Memcached servers in the config/cache.php file.

'memcached' => [
    [
        'host' => '127.0.0.1',
        'port' => 11211,
        'weight' => 100
    ],
],
Enter fullscreen mode Exit fullscreen mode

Read More

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay