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

Saturday, November 12, 2022

[FIXED] how to use Memcache with symfony

 November 12, 2022     memcached, php, session, symfony     No comments   

Issue

I using symfony 2 and I want to use Memcache with it but the problem is I can't find any explain for Memcache I just found for memcached so are they the same setup steps ? I added this lines to install Memcache on symfony?

config.yml

framework:
  session:
    handler_id: session.handler.memcached

for parameters.yml

parameters:   
  memcached_host: 127.0.0.1
  memcached_port: 11211
  memcached_prefix: custom_key_
  memcached_expire: 14400

services.yml

services:
  session.handler.memcached:
    class: Symfony\Component\HttpFoundation\Session\Storage\Handler\MemcachedSessionHandler
    arguments: [ "@session.memcached", { prefix: '%memcached_prefix%', expiretime: '%memcached_expire%' } ]


services:
  session.memcached:
    class: Memcached
    arguments:
      persistent_id: %memcached_prefix%
    calls:
      - [ addServer, [ %memcached_host%, %memcached_port% ]]



services:
  session.memcached:
    class: Madisoft\AppBundle\Utils\MemcachedWrapper
    arguments:
      persistent_id: '%memcached_prefix%'
    calls:
      - [ addServer, [ '%memcached_host%', '%memcached_port%' ] ]

Solution

There is only one Memcached software, and it's the one available at https://memcached.org/.

There are two well-known PHP libraries for Memcached, called memcache (http://php.net/manual/en/book.memcache.php) and memcached (http://php.net/manual/en/book.memcached.php), so this is probably where your confusion comes from.

To use Memcached with Symfony 2 I suggest to use an external bundle by LeaseWeb which provides all the required documentation: https://github.com/LeaseWeb/LswMemcacheBundle.

Starting with Symfony 3.3 there will be a native Memcached adapter: see http://symfony.com/blog/new-in-symfony-3-3-memcached-cache-adapter.



Answered By - Francesco Abeni
Answer Checked By - Candace Johnson (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