I want to use apc_store()
to cache some results.
But I need to know where the data will be stored, and what's the limit.
Does it always store on memory? Or also writes to disk? I would prefer that the data that is not accessed very frequently is stored on disk. Should I use a different caching system for that?
Is this the limit? apc.shm_size = 32MB
. If so, what happens when I exceed it?
APC always stores data in memory, it's designed for that and nothing else. You can't have APC write data to disk but you can of course implement several different storage adapters for your caching needs. If you want some things to be stored on disk, implement a file adapter. The different size settings are indeed how much memory you allocate to APC and if you exceed it, APC will start dumping LIFO. This should only impact your performance and nothing else. Your app needs to be able to function with or without cache. If that is not the case, you're abusing the idea of caching for persistence.
APC will store it in the memory.
you can set the size you want to use using apc.shm_size
this is a link explaning how APC works. http://lampzone.wordpress.com/2010/03/26/how-does-apc-work/
And the list fo all APC settings http://php.net/manual/en/apc.configuration.php
Data stored in the APC variable cache via
apc_store()
is always stored in memory. If you need to store more data than this makes sense for, you'll need to come up with some other caching solution yourself.The
apc.shm_size
configuration directive sets the size of the whole APC shared memory cache, which is used for both opcodes and user variables. If you write more data to the cache than specified here, elements will be dropped from the cache, starting with the least recently used. Your code needs to be able to deal with this -- it's a cache, after all, not a database.