XCache is a fast, stable PHP opcode cacher that has been proven and is now running on production servers under high load. https://xcache.lighttpd.net/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

237 lines
5.2 KiB

  1. #ifndef XC_CACHE_H_684B099102B4651FB10058EF6F7E80CE
  2. #define XC_CACHE_H_684B099102B4651FB10058EF6F7E80CE
  3. #if _MSC_VER > 1000
  4. #pragma once
  5. #endif /* _MSC_VER > 1000 */
  6. #include "xcache.h"
  7. #include "xcache/xc_compatibility.h"
  8. typedef ulong xc_hash_value_t;
  9. typedef struct _xc_hash_t xc_hash_t;
  10. typedef struct _xc_entry_t xc_entry_t;
  11. typedef struct _xc_entry_data_php_t xc_entry_data_php_t;
  12. struct _xc_lock_t;
  13. struct _xc_shm_t;
  14. /* {{{ xc_cache_t */
  15. typedef struct {
  16. int cacheid;
  17. xc_hash_t *hcache; /* hash to cacheid */
  18. time_t compiling;
  19. zend_ulong updates;
  20. zend_ulong hits;
  21. zend_ulong clogs;
  22. zend_ulong ooms;
  23. zend_ulong errors;
  24. struct _xc_lock_t *lck;
  25. struct _xc_shm_t *shm; /* which shm contains us */
  26. struct _xc_mem_t *mem; /* which mem contains us */
  27. xc_entry_t **entries;
  28. int entries_count;
  29. xc_entry_data_php_t **phps;
  30. int phps_count;
  31. xc_entry_t *deletes;
  32. int deletes_count;
  33. xc_hash_t *hentry; /* hash settings to entry */
  34. xc_hash_t *hphp; /* hash settings to php */
  35. time_t last_gc_deletes;
  36. time_t last_gc_expires;
  37. time_t hits_by_hour_cur_time;
  38. zend_uint hits_by_hour_cur_slot;
  39. zend_ulong hits_by_hour[24];
  40. time_t hits_by_second_cur_time;
  41. zend_uint hits_by_second_cur_slot;
  42. zend_ulong hits_by_second[5];
  43. } xc_cache_t;
  44. /* }}} */
  45. /* {{{ xc_op_array_info_detail_t */
  46. typedef struct {
  47. zend_uint index;
  48. zend_uint info;
  49. } xc_op_array_info_detail_t;
  50. /* }}} */
  51. /* {{{ xc_op_array_info_t */
  52. typedef struct {
  53. #ifdef ZEND_ENGINE_2_4
  54. zend_uint literalinfo_cnt;
  55. xc_op_array_info_detail_t *literalinfos;
  56. #else
  57. zend_uint oplineinfo_cnt;
  58. xc_op_array_info_detail_t *oplineinfos;
  59. #endif
  60. } xc_op_array_info_t;
  61. /* }}} */
  62. /* {{{ xc_classinfo_t */
  63. typedef struct {
  64. #ifdef IS_UNICODE
  65. zend_uchar type;
  66. #endif
  67. const24_zstr key;
  68. zend_uint key_size;
  69. ulong h;
  70. zend_uint methodinfo_cnt;
  71. xc_op_array_info_t *methodinfos;
  72. xc_cest_t cest;
  73. #ifndef ZEND_COMPILE_DELAYED_BINDING
  74. int oplineno;
  75. #endif
  76. } xc_classinfo_t;
  77. /* }}} */
  78. #ifdef HAVE_XCACHE_CONSTANT
  79. /* {{{ xc_constinfo_t */
  80. typedef struct {
  81. #ifdef IS_UNICODE
  82. zend_uchar type;
  83. #endif
  84. const24_zstr key;
  85. zend_uint key_size;
  86. ulong h;
  87. zend_constant constant;
  88. } xc_constinfo_t;
  89. /* }}} */
  90. #endif
  91. /* {{{ xc_funcinfo_t */
  92. typedef struct {
  93. #ifdef IS_UNICODE
  94. zend_uchar type;
  95. #endif
  96. const24_zstr key;
  97. zend_uint key_size;
  98. ulong h;
  99. xc_op_array_info_t op_array_info;
  100. zend_function func;
  101. } xc_funcinfo_t;
  102. /* }}} */
  103. #ifdef ZEND_ENGINE_2_1
  104. /* {{{ xc_autoglobal_t */
  105. typedef struct {
  106. #ifdef IS_UNICODE
  107. zend_uchar type;
  108. #endif
  109. const24_zstr key;
  110. zend_uint key_len;
  111. ulong h;
  112. } xc_autoglobal_t;
  113. /* }}} */
  114. #endif
  115. typedef struct {
  116. char digest[16];
  117. } xc_md5sum_t;
  118. struct _xc_compilererror_t;
  119. /* {{{ xc_entry_data_php_t */
  120. struct _xc_entry_data_php_t {
  121. xc_entry_data_php_t *next;
  122. xc_hash_value_t hvalue;
  123. xc_md5sum_t md5; /* md5sum of the source */
  124. zend_ulong refcount; /* count of entries referencing to this data */
  125. zend_ulong hits; /* hits of this php */
  126. size_t size;
  127. xc_op_array_info_t op_array_info;
  128. zend_op_array *op_array;
  129. #ifdef HAVE_XCACHE_CONSTANT
  130. zend_uint constinfo_cnt;
  131. xc_constinfo_t *constinfos;
  132. #endif
  133. zend_uint funcinfo_cnt;
  134. xc_funcinfo_t *funcinfos;
  135. zend_uint classinfo_cnt;
  136. xc_classinfo_t *classinfos;
  137. #ifndef ZEND_COMPILE_DELAYED_BINDING
  138. zend_bool have_early_binding;
  139. #endif
  140. #ifdef ZEND_ENGINE_2_1
  141. zend_uint autoglobal_cnt;
  142. xc_autoglobal_t *autoglobals;
  143. #endif
  144. #ifdef XCACHE_ERROR_CACHING
  145. zend_uint compilererror_cnt;
  146. struct _xc_compilererror_t *compilererrors;
  147. #endif
  148. zend_bool have_references;
  149. };
  150. /* }}} */
  151. typedef zvalue_value xc_entry_name_t;
  152. /* {{{ xc_entry_t */
  153. struct _xc_entry_t {
  154. xc_entry_t *next;
  155. size_t size;
  156. time_t ctime; /* creation ctime of this entry */
  157. time_t atime; /* access atime of this entry */
  158. time_t dtime; /* deletion time of this entry */
  159. zend_ulong hits;
  160. zend_ulong ttl;
  161. xc_entry_name_t name;
  162. };
  163. typedef struct {
  164. xc_entry_t entry;
  165. xc_entry_data_php_t *php;
  166. zend_ulong refcount; /* count of php instances holding this entry */
  167. time_t file_mtime;
  168. size_t file_size;
  169. int file_device;
  170. int file_inode;
  171. int filepath_len;
  172. ZEND_24(NOTHING, const) char *filepath;
  173. int dirpath_len;
  174. char *dirpath;
  175. #ifdef IS_UNICODE
  176. int ufilepath_len;
  177. UChar *ufilepath;
  178. int udirpath_len;
  179. UChar *udirpath;
  180. #endif
  181. } xc_entry_php_t;
  182. typedef struct {
  183. xc_entry_t entry;
  184. #ifdef IS_UNICODE
  185. zend_uchar name_type;
  186. #endif
  187. zval *value;
  188. zend_bool have_references;
  189. } xc_entry_var_t;
  190. /* }}} */
  191. typedef struct xc_entry_hash_t { /* {{{ */
  192. xc_hash_value_t cacheid;
  193. xc_hash_value_t entryslotid;
  194. } xc_entry_hash_t;
  195. /* }}} */
  196. int xc_is_rw(const void *p);
  197. int xc_is_ro(const void *p);
  198. int xc_is_shm(const void *p);
  199. /* {{{ xc_gc_op_array_t */
  200. typedef struct {
  201. #ifdef ZEND_ENGINE_2
  202. zend_uint num_args;
  203. zend_arg_info *arg_info;
  204. #endif
  205. zend_op *opcodes;
  206. } xc_gc_op_array_t;
  207. /* }}} */
  208. void xc_gc_add_op_array(xc_gc_op_array_t *gc_op_array TSRMLS_DC);
  209. void xc_fix_op_array_info(const xc_entry_php_t *xce, const xc_entry_data_php_t *php, zend_op_array *op_array, int shallow_copy, const xc_op_array_info_t *op_array_info TSRMLS_DC);
  210. #endif /* XC_CACHE_H_684B099102B4651FB10058EF6F7E80CE */