UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'TcZHPJB9O+76PQ5pStoIoCUgy2iKhKGHeNEboAe7mg0='
WHERE
key_id = 'ad2f84462e14e2df3921f81929f0e6d1daa6810d6278afd391accb7dd959bee7'
AND (
token = 'TcZHPJB9O+76PQ5pStoIoCUgy2iKhKGHeNEboAe7mg0='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)