-
- defaults('ADMIN_USERNAME','apc'); // Admin Username
- defaults('ADMIN_PASSWORD','password'); // Admin Password - CHANGE THIS TO ENABLE!!!
Copy code
3. apc usage example
APC is very simple to use. See the following examples of adding, querying, modifying, and deleting.
1), add a cache, the effective time is 3600 seconds
apc_add('name', 'tom', 3600);
Execute the code, and then check the User Cache Entries. You can see that there is an additional cache data with the key value name:
Among them are the number of hits, size, expiration time, etc.
2) Query cache
-
- apc_add('name', 'tom', 3600);
- print apc_fetch('name'); //Output tom
-
Copy code
3), modify cache
-
- apc_store('name', 'anny', 3600);
- print apc_fetch('name'); //Output anny
-
Copy code
4), delete cache
-
- apc_delete('name');
- var_dump(apc_fetch('name')); //Output bool(false)
Copy code
5), increasing and decreasing numbers
If the cached content is a number, you can use apc_ inc to increase by 1 and apc_dec to decrease by 1.
-
- apc_add('num', 10);
- apc_inc('num');
- print apc_fetch('num');//Output 11
- apc_dec('num');
- print apc_fetch('num ');//Output 10
Copy code
6), determine whether the cache exists
-
- apc_add('name', 'tom', 3600);
- var_dump(apc_exists('name')); //Output bool(true)
- var_dump(apc_exists('age')); // bool(false)
Copy code
|