Skip to content

Commit 3f0ebc4

Browse files
committed
3.0.0 new API design, more performance improvements
1 parent 11240f5 commit 3f0ebc4

189 files changed

Lines changed: 5449 additions & 2860 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Zend/zend.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ extern ZEND_API void (*zend_post_shutdown_cb)(void);
387387
extern ZEND_API void (*zend_accel_schedule_restart_hook)(int reason);
388388

389389
/* These hooks are used by OPcache Static Cache to restore, publish, and track
390-
* selected VolatileStatic and PinnedStatic state across requests. They remain
390+
* selected VolatileStatic and StableStatic state across requests. They remain
391391
* NULL when the static-cache subsystem is not active. */
392392
extern ZEND_API void (*zend_class_init_statics_hook)(zend_class_entry *ce);
393393
extern ZEND_API void (*zend_function_init_statics_hook)(zend_execute_data *execute_data);

ext/opcache/ZendAccelerator.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3544,7 +3544,7 @@ static zend_result accel_post_startup(void)
35443544
/* Initialize static cache if configured */
35453545
bool static_cache_configured =
35463546
ZCG(accel_directives).static_cache_volatile_size_mb != 0 ||
3547-
ZCG(accel_directives).static_cache_pinned_size_mb != 0
3547+
ZCG(accel_directives).static_cache_stable_size_mb != 0
35483548
;
35493549
bool static_cache_preload_configured = static_cache_configured &&
35503550
ZCG(accel_directives).preload &&

ext/opcache/ZendAccelerator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ void zend_accel_register_static_cache_handlers(const zend_opcache_static_cache_a
151151
typedef struct _zend_accel_directives {
152152
zend_long memory_consumption;
153153
zend_long static_cache_volatile_size_mb;
154-
zend_long static_cache_pinned_size_mb;
154+
zend_long static_cache_stable_size_mb;
155155
zend_long max_accelerated_files;
156156
double max_wasted_percentage;
157157
char *user_blacklist_filename;

ext/opcache/opcache.stub.php

Lines changed: 87 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
function opcache_reset(): bool {}
88

9+
function opcache_static_cache_volatile_reset(): bool {}
10+
911
/**
1012
* @return array<string, mixed>|false
1113
* @refcount 1
@@ -63,7 +65,7 @@ private function __construct() {}
6365
}
6466

6567
#[\Attribute(13)] /* TARGET_CLASS | TARGET_METHOD | TARGET_PROPERTY */
66-
final class PinnedStatic
68+
final class StableStatic
6769
{
6870
}
6971

@@ -92,68 +94,126 @@ final class VolatileStatic
9294
public function __construct(int $ttl = 0, CacheStrategy $strategy = CacheStrategy::Immediate) {}
9395
}
9496

95-
final class VolatileCache
97+
interface StaticCacheInterface
9698
{
97-
public static function get(string $key, null|bool|int|float|string|array|object $default = null): null|bool|int|float|string|array|object {}
99+
public static function getInstance(string $pool_name): static;
100+
101+
public function fetch(string $key, null|bool|int|float|string|array|object $default = null): null|bool|int|float|string|array|object;
98102

99103
/**
100104
* @return array<string, null|bool|int|float|string|array|object>|false
101105
*/
102-
public static function getMultiple(array $keys, ?array $default = null): array|false {}
106+
public function fetchMultiple(array $keys, ?array $default = null): array|false;
107+
108+
public function store(string $key, null|bool|int|float|string|array|object $value): bool;
109+
110+
public function storeMultiple(array $values): bool;
111+
112+
public function has(string $key): bool;
103113

104-
public static function set(string $key, null|bool|int|float|string|array|object $value, int $ttl = 0): bool {}
114+
public function delete(string $key): bool;
105115

106-
public static function setMultiple(array $values, int $ttl = 0): bool {}
116+
public function deleteMultiple(array $keys): bool;
107117

108-
public static function has(string $key): bool {}
118+
public function clear(): bool;
109119

110-
public static function delete(string $key_or_class): bool {}
120+
public function lock(string $key, int $lease = 0): bool;
111121

112-
public static function deleteMultiple(array $keys): bool {}
122+
public function unlock(string $key): bool;
113123

114-
public static function clear(): bool {}
124+
public function getCacheStoreType(string $key): CacheStoreType;
125+
126+
public static function info(): StaticCacheInfo;
127+
128+
public static function getCacheStoreTypeByProperty(string $class_name, string $property_name): CacheStoreType;
129+
130+
public static function getCacheStoreTypeByMethod(string $class_name, string $method_name, string $variable_name): CacheStoreType;
131+
}
115132

116-
public static function lock(string $key, int $lease = 0): bool {}
133+
/** @not-serializable */
134+
final class VolatileCache implements StaticCacheInterface
135+
{
136+
private function __construct() {}
137+
138+
public static function getInstance(string $pool_name): static {}
139+
140+
public function fetch(string $key, null|bool|int|float|string|array|object $default = null): null|bool|int|float|string|array|object {}
141+
142+
/**
143+
* @return array<string, null|bool|int|float|string|array|object>|false
144+
*/
145+
public function fetchMultiple(array $keys, ?array $default = null): array|false {}
117146

118-
public static function unlock(string $key): bool {}
147+
public function store(string $key, null|bool|int|float|string|array|object $value): bool {}
119148

120-
public static function getCacheStoreType(string $key_or_property, ?string $class_name = null): CacheStoreType {}
149+
public function storeMultiple(array $values): bool {}
150+
151+
public function has(string $key): bool {}
152+
153+
public function delete(string $key): bool {}
154+
155+
public function deleteMultiple(array $keys): bool {}
156+
157+
public function clear(): bool {}
158+
159+
public function lock(string $key, int $lease = 0): bool {}
160+
161+
public function unlock(string $key): bool {}
162+
163+
public function getCacheStoreType(string $key): CacheStoreType {}
121164

122165
public static function info(): StaticCacheInfo {}
166+
167+
public static function getCacheStoreTypeByProperty(string $class_name, string $property_name): CacheStoreType {}
168+
169+
public static function getCacheStoreTypeByMethod(string $class_name, string $method_name, string $variable_name): CacheStoreType {}
123170
}
124171

125-
final class PinnedCache
172+
/** @not-serializable */
173+
final class StableCache implements StaticCacheInterface
126174
{
127-
public static function get(string $key, null|bool|int|float|string|array|object $default = null): null|bool|int|float|string|array|object {}
175+
private function __construct() {}
176+
177+
public static function getInstance(string $pool_name): static {}
178+
179+
public function fetch(string $key, null|bool|int|float|string|array|object $default = null): null|bool|int|float|string|array|object {}
128180

129181
/**
130182
* @return array<string, null|bool|int|float|string|array|object>|false
131183
*/
132-
public static function getMultiple(array $keys, ?array $default = null): array|false {}
184+
public function fetchMultiple(array $keys, ?array $default = null): array|false {}
133185

134-
public static function set(string $key, null|bool|int|float|string|array|object $value): bool {}
186+
public function store(string $key, null|bool|int|float|string|array|object $value): bool {}
135187

136-
public static function setMultiple(array $values): bool {}
188+
public function storeMultiple(array $values): bool {}
137189

138-
public static function has(string $key): bool {}
190+
public function storeWithTtl(string $key, null|bool|int|float|string|array|object $value, int $ttl): bool {}
139191

140-
public static function delete(string $key_or_class): bool {}
192+
public function storeMultipleWithTtl(array $values, int $ttl): bool {}
141193

142-
public static function deleteMultiple(array $keys): bool {}
194+
public function has(string $key): bool {}
143195

144-
public static function clear(): bool {}
196+
public function delete(string $key): bool {}
145197

146-
public static function lock(string $key, int $lease = 0): bool {}
198+
public function deleteMultiple(array $keys): bool {}
147199

148-
public static function unlock(string $key): bool {}
200+
public function clear(): bool {}
149201

150-
public static function increment(string $key, int $step = 1): int|false {}
202+
public function lock(string $key, int $lease = 0): bool {}
151203

152-
public static function decrement(string $key, int $step = 1): int|false {}
204+
public function unlock(string $key): bool {}
153205

154-
public static function getCacheStoreType(string $key_or_property, ?string $class_name = null): CacheStoreType {}
206+
public function increment(string $key, int $step = 1): int|false {}
207+
208+
public function decrement(string $key, int $step = 1): int|false {}
209+
210+
public function getCacheStoreType(string $key): CacheStoreType {}
155211

156212
public static function info(): StaticCacheInfo {}
213+
214+
public static function getCacheStoreTypeByProperty(string $class_name, string $property_name): CacheStoreType {}
215+
216+
public static function getCacheStoreTypeByMethod(string $class_name, string $method_name, string $variable_name): CacheStoreType {}
157217
}
158218

159219
}

0 commit comments

Comments
 (0)