Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the maximum key length for PHP APC?

Tags:

php

apc

You would think this would be super-easy to find, but I can't seem to.

like image 861
Christophe Avatar asked May 05 '11 00:05

Christophe


People also ask

What is APCu PHP?

APCu is an in-memory key-value store for PHP. Keys are of type string and values can be any PHP variables. APCu only supports userland caching of variables. APCu is APC stripped of opcode caching. The first APCu codebase was versioned 4.0.

What is APCu extension?

The APCu extension adds object caching functions to PHP. APCu is the official replacement for the outdated APC extension. APC provided both opcode caching (opcache) and object caching. As PHP versions 5.5 and above include their own opcache, APC was no longer compatible, and its opcache functionality became useless.


2 Answers

There appears to be no limitation on key size/content.

Internally, keys are initialized via the C function apc_cache_make_user_key, which takes the given key string ("identifier") and stores it along with a hashed version.

like image 106
Steve Clay Avatar answered Oct 14 '22 22:10

Steve Clay


I really don't know PHP, but it looks like values are added using apc_add() or apc_store(), which take keys which are strings. I would infer that the maximum key length is therefore the maximum length of a string in PHP.

According to PHP: Strings,

Note: It is no problem for a string to become very large. PHP imposes no boundary on the size of a string; the only limit is the available memory of the computer on which PHP is running.

like image 24
Matt Ball Avatar answered Oct 14 '22 20:10

Matt Ball