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