PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, November 12, 2022

[FIXED] How to use memcached and apc together in laravel?

 November 12, 2022     apc, laravel, laravel-5, memcached, php     No comments   

Issue

I want to use both memcached and apc at the same time for caching, how can I configure and use it in laravel.


Solution

By using the Cache facade you can specify what cache type you want to use.

Cache::store('memcached')->put('bar', 'baz', 10); // Using memcached
Cache::store('apc')->put('bar', 'baz', 10); // Using apc

As you can see in your app/config/cache.php there is already some preconfigured cache types set up:

'stores' => [

        'apc' => [
            'driver' => 'apc',
        ],

        'array' => [
            'driver' => 'array',
        ],

        'database' => [
            'driver' => 'database',
            'table' => 'cache',
            'connection' => null,
        ],

        'file' => [
            'driver' => 'file',
            'path' => storage_path('framework/cache'),
        ],

        'memcached' => [
            'driver' => 'memcached',
            'servers' => [
                [
                    'host' => env('MEMCACHED_HOST', '127.0.0.1'),
                    'port' => env('MEMCACHED_PORT', 11211),
                    'weight' => 100,
                ],
            ],
        ],

        'redis' => [
            'driver' => 'redis',
            'connection' => 'default',
        ],

    ],

You now need to make sure, memcached and APC are correctly installed on your system.

  • Using the Memcached cache requires the Memcached PECL package to be installed.
  • Using APC cache requires the APC package on your system


Answered By - codedge
Answer Checked By - Dawn Plyler (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing