UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'KCtTA5lvFZSaFo6KVg51LGpWpLp+975Oadwgq7h1cgs='
WHERE
key_id = '319c4cdda4681b17e53814ba91d0c31be880cdaae8fb22815e1657c58fb2d661'
AND (
token = 'KCtTA5lvFZSaFo6KVg51LGpWpLp+975Oadwgq7h1cgs='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)