I'm very new to APC Cache with PHP-FPM. Below are my current settings for a nginx/php webserver serving dynamic pages - 4GB RAM.

Do I need to have 'User Cache' enabled? as it doesn't appear to be used.

Also can anyone give any advice around these settings - I'm currently reading, learning and attempting to tune this but any advice would be greatly appreciated. thx

Note: the settings run out of php.ini (I assume that is standard).

General Cache Information
APC Version 3.1.15-dev
PHP Version 5.4.23

Server Software nginx/1.4.4
Shared Memory   1 Segment(s) with 64.0 MBytes 
(mmap memory, pthread mutex Locks locking)
Start Time  2014/01/04 05:04:13
Uptime  22 minutes
File Upload Support 1

File Cache Information
Cached Files    13 (483.2 KBytes)
Hits    51655
Misses  18
Request Rate (hits, misses) 38.71 cache requests/second
Hit Rate    38.69 cache requests/second
Miss Rate   0.01 cache requests/second
Insert Rate 0.01 cache requests/second
Cache full count    0

User Cache Information
Cached Variables    0 ( 0.0 Bytes)
Hits    0
Misses  0
Request Rate (hits, misses) 0.00 cache requests/second
Hit Rate    0.00 cache requests/second
Miss Rate   0.00 cache requests/second
Insert Rate 0.00 cache requests/second
Cache full count    0

Runtime Settings
apc.cache_by_default    1
apc.canonicalize    1
apc.coredump_unmap  0
apc.enable_cli  0
apc.enable_opcode_cache 1
apc.enabled 1
apc.file_md5    0
apc.file_update_protection  2
apc.filters 
apc.gc_ttl  3600
apc.include_once_override   0
apc.lazy_classes    0
apc.lazy_functions  0
apc.max_file_size   2M
apc.mmap_file_mask  /tmp/apc.vaREsm
apc.num_files_hint  1024
apc.preload_path    
apc.report_autofilter   0
apc.rfc1867 0
apc.rfc1867_freq    0
apc.rfc1867_name    APC_UPLOAD_PROGRESS
apc.rfc1867_prefix  upload_
apc.rfc1867_ttl 3600
apc.serializer  igbinary
apc.shm_segments    1
apc.shm_size    64M
apc.shm_strings_buffer  8M
apc.slam_defense    0
apc.stat    1
apc.stat_ctime  0
apc.ttl 7200
apc.use_request_time    1
apc.user_entries_hint   4096
apc.user_ttl    7200
apc.write_lock  1
有帮助吗?

解决方案

First you should understand what is a user cache to decide whether you should enable it or not. User cache means you cache data(save data) into APC. Now this could be an object, variable anything.

Lets say you get user profile from database, and you want to cache it so the next requests wont be needing to fetch from db. You would cache it in APC after the first fetch from db. this is an example of where you might use APC user cache

         $userObject->name = "Mike";
         $userObject-> age = 12;
         apc_store("user", $userObject);

You can retrieve the value, with the key which is user.

        var_dump(apc_fetch("user"));

THats user cache

Have a look at this site about Perfect APC configuration:

Perfect APC configuration

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top