UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'CgCKasvzy7KJ/zMkN6pIPvUcwXKBSfafGLjPI1I/LjM='
WHERE
key_id = '8477d34583bb7bf3084130492f8c1f7f67236553ff61d7a6642dfec0746ae7f1'
AND (
token = 'CgCKasvzy7KJ/zMkN6pIPvUcwXKBSfafGLjPI1I/LjM='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)