magento2 – delete compare list rest api

I am building a residual API to clear the list of predicates

Here is the code I use

        / **
* @api
*
* @return int
* /
public function clearItems () {
$ id = $ this-> userContext-> getUserId ();
$ userType = $ this-> userContext-> getUserType ();
$ this-> collection-> setVisitorId ($ id);
if ($ userType === UserContextInterface :: USER_TYPE_CUSTOMER) {
$ this-> item-> setCustomerId ($ id);
}


$ this-> collection-> clear ();

return $ id;
}

However, it is only deleted from the database and remains in the store. and when the comparison list from the shop was opened, she returned to the database
The returned ID differs from the logged in user ID