source: trunk/mod_cacher/xc_cache.h

Last change on this file was 1558, checked in by moo, 2 weeks ago

closes #342: object caching

  • Property svn:eol-style set to native
File size: 4.9 KB
Line 
1#ifndef XC_CACHE_H_684B099102B4651FB10058EF6F7E80CE
2#define XC_CACHE_H_684B099102B4651FB10058EF6F7E80CE
3
4#if _MSC_VER > 1000
5#pragma once
6#endif /* _MSC_VER > 1000 */
7
8#include "xcache.h"
9#include "xcache/xc_compatibility.h"
10
11typedef ulong xc_hash_value_t;
12typedef struct _xc_hash_t xc_hash_t;
13typedef struct _xc_cached_t xc_cached_t;
14typedef struct _xc_entry_t xc_entry_t;
15typedef struct _xc_entry_data_php_t xc_entry_data_php_t;
16
17struct _xc_lock_t;
18struct _xc_shm_t;
19/* {{{ xc_constant_info_t */
20typedef struct {
21    zend_uint index;
22    zend_uint info;
23} xc_constant_info_t;
24/* }}} */
25/* {{{ xc_op_array_info_t */
26typedef struct {
27    zend_uint           constantinfo_cnt;
28    xc_constant_info_t *constantinfos;
29} xc_op_array_info_t;
30/* }}} */
31/* {{{ xc_classinfo_t */
32typedef struct {
33#ifdef IS_UNICODE
34    zend_uchar          type;
35#endif
36    const24_zstr        key;
37    zend_uint           key_size;
38    ulong               h;
39    zend_uint           methodinfo_cnt;
40    xc_op_array_info_t *methodinfos;
41#ifdef ZEND_ENGINE_2
42    zend_uint           constantinfo_cnt;
43    xc_constant_info_t *constantinfos;
44#endif
45    xc_cest_t           cest;
46#ifndef ZEND_COMPILE_DELAYED_BINDING
47    int                 oplineno;
48#endif
49} xc_classinfo_t;
50/* }}} */
51#ifdef HAVE_XCACHE_CONSTANT
52/* {{{ xc_constinfo_t */
53typedef struct {
54#ifdef IS_UNICODE
55    zend_uchar    type;
56#endif
57    const24_zstr  key;
58    zend_uint     key_size;
59    ulong         h;
60    zend_constant constant;
61} xc_constinfo_t;
62/* }}} */
63#endif
64/* {{{ xc_funcinfo_t */
65typedef struct {
66#ifdef IS_UNICODE
67    zend_uchar     type;
68#endif
69    const24_zstr   key;
70    zend_uint      key_size;
71    ulong          h;
72    xc_op_array_info_t op_array_info;
73    zend_function func;
74} xc_funcinfo_t;
75/* }}} */
76#ifdef ZEND_ENGINE_2_1
77/* {{{ xc_autoglobal_t */
78typedef struct {
79#ifdef IS_UNICODE
80    zend_uchar   type;
81#endif
82    const24_zstr key;
83    zend_uint    key_len;
84    ulong        h;
85} xc_autoglobal_t;
86/* }}} */
87#endif
88
89typedef struct {
90    char digest[16];
91} xc_md5sum_t;
92struct _xc_compilererror_t;
93/* {{{ xc_entry_data_php_t */
94struct _xc_entry_data_php_t {
95    xc_entry_data_php_t *next;
96    xc_hash_value_t      hvalue;
97
98    xc_md5sum_t md5;        /* md5sum of the source */
99    zend_ulong  refcount;   /* count of entries referencing to this data */
100
101    zend_ulong hits;        /* hits of this php */
102    size_t     size;
103
104    xc_op_array_info_t op_array_info;
105    zend_op_array *op_array;
106
107#ifdef HAVE_XCACHE_CONSTANT
108    zend_uint constinfo_cnt;
109    xc_constinfo_t *constinfos;
110#endif
111
112    zend_uint funcinfo_cnt;
113    xc_funcinfo_t *funcinfos;
114
115    zend_uint classinfo_cnt;
116    xc_classinfo_t *classinfos;
117#ifndef ZEND_COMPILE_DELAYED_BINDING
118    zend_bool have_early_binding;
119#endif
120
121#ifdef ZEND_ENGINE_2_1
122    zend_uint autoglobal_cnt;
123    xc_autoglobal_t *autoglobals;
124#endif
125
126#ifdef XCACHE_ERROR_CACHING
127    zend_uint compilererror_cnt;
128    struct _xc_compilererror_t *compilererrors;
129#endif
130
131    zend_bool  have_references;
132};
133/* }}} */
134typedef zvalue_value xc_entry_name_t;
135/* {{{ xc_entry_t */
136struct _xc_entry_t {
137    xc_entry_t *next;
138
139    size_t     size;
140    time_t     ctime;           /* creation ctime of this entry */
141    time_t     atime;           /*   access atime of this entry */
142    time_t     dtime;           /*  deletion time of this entry */
143    zend_ulong hits;
144    zend_ulong ttl;
145
146    xc_entry_name_t name;
147};
148
149typedef struct {
150    char  *str;
151    size_t len;
152} xc_constant_string_t;
153
154#ifdef IS_UNICODE
155typedef struct {
156    UChar  *str;
157    size_t len;
158} xc_constant_u_string_t;
159#endif
160
161typedef struct {
162    xc_entry_t entry;
163    xc_entry_data_php_t *php;
164
165    zend_ulong refcount;    /* count of php instances holding this entry */
166    time_t file_mtime;
167    size_t file_size;
168    size_t file_device;
169    size_t file_inode;
170
171    xc_constant_string_t filepath;
172#ifdef ZEND_ENGINE_2_3
173    xc_constant_string_t dirpath;
174#endif
175#ifdef IS_UNICODE
176    xc_constant_u_string_t u_filepath;
177    xc_constant_u_string_t u_dirpath;
178#endif
179} xc_entry_php_t;
180
181typedef struct {
182    xc_entry_t entry;
183#ifdef IS_UNICODE
184    zend_uchar name_type;
185#endif
186    zval      *value;
187
188#ifdef ZEND_ENGINE_2
189    zend_uint objects_count;
190    zend_object *objects;
191#endif
192    zend_uint class_names_count;
193    xc_constant_string_t *class_names;
194
195    zend_bool  have_references;
196} xc_entry_var_t;
197/* }}} */
198typedef struct xc_entry_hash_t { /* {{{ */
199    xc_hash_value_t cacheid;
200    xc_hash_value_t entryslotid;
201} xc_entry_hash_t;
202/* }}} */
203
204zend_bool xc_is_rw(const void *p);
205zend_bool xc_is_ro(const void *p);
206zend_bool xc_is_shm(const void *p);
207/* {{{ xc_gc_op_array_t */
208typedef struct {
209#ifdef ZEND_ENGINE_2
210    zend_uint num_args;
211    zend_arg_info *arg_info;
212#endif
213#ifdef ZEND_ENGINE_2_4
214    zend_literal *literals;
215#endif
216    zend_op *opcodes;
217} xc_gc_op_array_t;
218/* }}} */
219void xc_gc_add_op_array(xc_gc_op_array_t *gc_op_array TSRMLS_DC);
220#ifdef ZEND_ENGINE_2
221void xc_fix_class_info(const xc_entry_php_t *entry_php, xc_classinfo_t *classinfo, int shallow_copy TSRMLS_DC);
222#endif
223void xc_fix_op_array_info(const xc_entry_php_t *xce, zend_op_array *op_array, int shallow_copy, const xc_op_array_info_t *op_array_info TSRMLS_DC);
224
225#endif /* XC_CACHE_H_684B099102B4651FB10058EF6F7E80CE */
Note: See TracBrowser for help on using the repository browser.