salix/db/routines/cache/procedures/cache_calc_end.sql

26 lines
731 B
SQL

DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `cache`.`cache_calc_end`(IN `v_calc` INT)
BEGIN
DECLARE v_cache_name VARCHAR(255);
DECLARE v_params VARCHAR(255);
-- Libera el bloqueo y actualiza la fecha de ultimo refresco.
UPDATE cache_calc cc JOIN cache c ON c.id = cc.cache_id
SET
cc.last_refresh = NOW(),
cc.expires = ADDTIME(NOW(), c.lifetime),
cc.connection_id = NULL
WHERE cc.id = v_calc;
SELECT c.name, ca.params INTO v_cache_name, v_params
FROM cache c
JOIN cache_calc ca ON c.id = ca.cache_id
WHERE ca.id = v_calc;
IF v_cache_name IS NOT NULL THEN
DO RELEASE_LOCK(CONCAT_WS('/', v_cache_name, IFNULL(v_params, '')));
END IF;
END$$
DELIMITER ;