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