Untitled
unknown
plain_text
2 years ago
841 B
7
Indexable
function schedule_flush_cache($post_id, $coupon) {
// Pobierz datę opublikowania kuponu
$publish_date = get_post_time('U', false, $post_id);
// Dodaj minutę do daty opublikowania
$scheduled_time = $publish_date + 60;
// Zaplanuj zadanie CRON
wp_schedule_single_event($scheduled_time, 'flush_redis_cache');
}
add_action('woocommerce_coupon_options_save', 'schedule_flush_cache', 10, 2);
function flush_redis_cache() {
// Sprawdź, czy klasa Redis jest dostępna
if (class_exists('Redis')) {
$redis = new Redis();
// Połącz z serwerem Redis
if ($redis->connect('127.0.0.1', 6379)) {
// Wyczyść całą pamięć podręczną Redis
$redis->flushAll();
}
}
}
add_action('flush_redis_cache', 'flush_redis_cache');
Editor is loading...