UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'ReibKHFwgdc4jqh81hIdbusT6KY54K4r2qhRUsd8Nv4='
WHERE
key_id = 'fe516451965183c573c87e9fe4c86eee6e7628947ce25f8fb6b23c3e7e5df6dc'
AND (
token = 'ReibKHFwgdc4jqh81hIdbusT6KY54K4r2qhRUsd8Nv4='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)