ZF2 PHP5.5 Cache Storage alternative for APC - php

I have been using ZF2 with PHP 5.3 and APC cache, and now I upgraded to PHP 5.5, and it seems there is no support for APC on PHP 5.5, I read that PHP5.5 have OpCache out of the box, but is it an alternative for APC? If yes How can I configure a Cache Storage Adapter for OpCache? if it is not to replace APC what can I use for PHP5.5? and how to configure an Adapter for it.

AFAIK OpCache differs from APC in that it's purely for caching scripts. You might want to take a look at the zf2 memcache adapter or hand roll your own with redis by implementing this interface. There are instructions here for implementing the interface, so it shouldn't be hard.
I use both memcache and redis extensively. I find memcache simpler but redis to have more functionality. If you only need a key-value store, i'd go with memcache as the adapter is pre-written.

Use the APCu like #ziollek's said. Starting from Php 5.5 Apc removed in favor of Opcache but APCu is a drop-in replacement for APC and it runs fully compatible with the good old APC.
So, Zend's APC cache storage adapter should work with APCu too.
See: https://github.com/krakjoe/apcu/issues/7

Related

Is there a PHP 5.5 buildpack with APC (Alternative PHP Cache)?

Can I use APC (Alternative PHP Cache) in my Bluemix PHP environment?
I added { "PHP_EXTENSIONS": ["apc"] } to my options.json file but when I tried that to deploy a message said that apc wasn't included in the buildpack. I need PHP 5.5 so I'm using php-buildpack#v4.3.2. Can you suggest a buildpack that includes APC?
I need an in-memory cache to replace Laravel's file cache. If I can't use APC, can anyone suggest anything else?
The Bluemix default PHP buildpack, which is listed in the admin catalog, is v4.1.5. This version supports both PHP 5.5 and APC. So you can bring your local environment to be compatible with PHP buildpack 4.1.5 to develop app on this version of buildpack.
PHP 5.5 and later come bundled with the OpCache, which supercedes the APC.
If you have code that uses the APC functions, you can continue using them in PHP 5.5 by using the APCu extension. APCu is APC, but with the opcache part removed (so that you can use the built-in OpCache instead), just leaving the memory cache and PHP functions to access it.
References:
http://jessesnet.com/development-notes/2014/php-55-opcache-apcu/
http://php.net/manual/en/migration55.new-features.php
http://php.net/manual/en/book.apcu.php
https://pecl.php.net/package/APCu
To close things out: I used php-buildpack#v4.1.5 which includes apc though it's based on PHP 5.4 so I had to down-level my guzzle to 5.3.0 which meant I needed to modify my guzzle code since I was using the guzzle 6 apis. I then changed my Laravel cache calls to use apc. Surprisingly, after all that the app still works, though whether it's really any faster is hard to tell

Opcache equivalent function to apc store

We need to upgrade the php version from 5.3 to 5.5 of one project that´s using APC. So, as I´ve seen in php 5.5 there is a new cache library to use instead of apc, opcache. I have read the docs and I have a few doubts.
Actually, in one specific part of the project we are using the apc store and fetch functions to store some data, but I haven´t seen any similar functions to do the same task with opcache. The question is simple, is it possible to do the same with opcache?
Thanks in advance.
You can restore the store and fetch functions by installing APCu
sudo apt-get install php5-apcu
By installing APCu extension_loaded('apc') will return true as well
and you don't need to rename any of the old functions used.
I'm using this on a debian with PHP5.6 with OPCache enabled
source
No you can not do it with OPCache. This module makes OPCode Caching only.

Switching from APC to APCu

I am running a web server with Debian and I'm hosting a ZF1 project.
The PHP process crashes from time to time without any reason, so my hosting provider suggests that I should switch from APC to APCu caching. I'm not very familiar with PHP caching and I can't really find any documentation on the topic, but I read a few similar questions here.
As far as I understand the APCu caches only user data (whatever that means) and it's not the full features of the APC. Considering this, my question is will APCu increase the load of the server and will the PHP extension work out of the box without touching the ZF1 code?
http://zend-framework-community.634137.n4.nabble.com/Does-ZF-1-12-support-PHP-5-5-td4661902.html
You should upgrade to the latest PHP on a test environment, if it works well (most likely scenario), you can switch. PHP 5.5 has built-in opcode cache (http://php.net/manual/en/intro.opcache.php), so you won't lose performance. Very little difference can be between the performance of APCu and APC.
Also, function names are not identical (apcu_fetch for instance), so you have to modify the code to reflect this.

Using APC in PHP 5.5

I want to functions like apc_store() and apc_fetch() in my PHP application (I never used APC before). However, my understanding is that APC cannot be installed on PHP 5.5+ because PHP 5.5+ has its own opcode cache. If I plan on upgrading to PHP 5.5+ in the future, should I use apc_* functions? If I shouldn't, are there "future safe" alternatives to APC?
As of 5.5 and onward I replaced on my setups APC with APCu. APCu is APC without the opcode caching. It also provides the apc_ functions and passes checks for extension_loaded('apc').
Make sure you use at least v4.0.2 of this extension. Prior releases had a bug in which the apc_ functions were not available even when the APC compat mode was turned on.
Also see the answers to this question.
The variable storage part of APC has been left in the APCU package. It's APC, without the code cache.

PHP memcache confusion on install

So looking into using memcache in my web application I am reading up about memcache and memcached. Just looking to clarify some things. First when they say install memcached that means install memcache right? Just the d is for the daemon correct? There isnt something different to install for memcached vs memcache correct?
Then the second is the php library, memcache vs memcached. Which I understand Im just a bit confused with the installation part when someone says install memcache then I read other posts that says install memcached. This is the url I was planning to use to install memcache, of course with the latest versions:
http://mrphp.com.au/code/install-memcache-cpanel-running-centos
You need to:
install memcached library into your OS
install the php-client to work with memcache. It could be Memcache or Memcached.
if you'll choose Memcached, you will need to install necessary libevent version
Memcache client is more stable, but Memcached has some interesting features.
Look at differences in functionality (just few functions) and if you really need these new features - take Memcached, otherwise - Memcache.

Categories