UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = '8PNQdzFMhMNYJmCiyjB8df42ZCYKHy8eSHwB+l1YJYI='
WHERE
key_id = 'f40afbff96401b8da004b6bd4c96f2d57fe466cd2f548d078baeda1e40aa0705'
AND (
token = '8PNQdzFMhMNYJmCiyjB8df42ZCYKHy8eSHwB+l1YJYI='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)