Changeset 3412927
- Timestamp:
- 12/06/2025 11:27:16 AM (4 months ago)
- Location:
- dynamic-front-end-heartbeat-control
- Files:
-
- 2 edited
-
tags/1.2.996.2/heartbeat-async.php (modified) (1 diff)
-
trunk/heartbeat-async.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
dynamic-front-end-heartbeat-control/tags/1.2.996.2/heartbeat-async.php
r3412883 r3412927 119 119 $cached = $detected; 120 120 return (int) $cached; 121 }122 }123 124 function dfehc_acquire_lock(string $base, int $ttl)125 {126 $key = dfehc_scoped_key($base);127 if (class_exists('WP_Lock')) {128 $lock = new WP_Lock($key, $ttl);129 if ($lock->acquire()) {130 return $lock;131 }132 return null;133 }134 if (function_exists('wp_cache_add') && wp_cache_add($key, 1, DFEHC_CACHE_GROUP, $ttl)) {135 return (object) ['cache_key' => $key];136 }137 if (get_transient($key) !== false) {138 return null;139 }140 if (set_transient($key, 1, $ttl)) {141 return (object) ['transient_key' => $key];142 }143 return null;144 }145 146 function dfehc_release_lock($lock): void147 {148 if ($lock instanceof WP_Lock) {149 $lock->release();150 return;151 }152 if (is_object($lock) && isset($lock->cache_key)) {153 wp_cache_delete($lock->cache_key, DFEHC_CACHE_GROUP);154 return;155 }156 if (is_object($lock) && isset($lock->transient_key)) {157 delete_transient($lock->transient_key);158 121 } 159 122 } -
dynamic-front-end-heartbeat-control/trunk/heartbeat-async.php
r3412883 r3412927 119 119 $cached = $detected; 120 120 return (int) $cached; 121 }122 }123 124 function dfehc_acquire_lock(string $base, int $ttl)125 {126 $key = dfehc_scoped_key($base);127 if (class_exists('WP_Lock')) {128 $lock = new WP_Lock($key, $ttl);129 if ($lock->acquire()) {130 return $lock;131 }132 return null;133 }134 if (function_exists('wp_cache_add') && wp_cache_add($key, 1, DFEHC_CACHE_GROUP, $ttl)) {135 return (object) ['cache_key' => $key];136 }137 if (get_transient($key) !== false) {138 return null;139 }140 if (set_transient($key, 1, $ttl)) {141 return (object) ['transient_key' => $key];142 }143 return null;144 }145 146 function dfehc_release_lock($lock): void147 {148 if ($lock instanceof WP_Lock) {149 $lock->release();150 return;151 }152 if (is_object($lock) && isset($lock->cache_key)) {153 wp_cache_delete($lock->cache_key, DFEHC_CACHE_GROUP);154 return;155 }156 if (is_object($lock) && isset($lock->transient_key)) {157 delete_transient($lock->transient_key);158 121 } 159 122 }
Note: See TracChangeset
for help on using the changeset viewer.