Your Question

I perform some Redis operations in AfterFind to prevent duplicate recommendations (do not return the current record), I read the documentation and issues and it is not resolved

The document you expected this should be explained

https://gorm.io/zh_CN/docs/hooks.html#%E6%9F%A5%E8%AF%A2%E5%AF%B9%E8%B1%A1

Expected answer

I can return an error, or call an api to not return this record

Comment From: keyvangholami

The AfterFind hook is not the place to filter or exclude records from the result set. It's invoked after the query has been executed and the results have been loaded. You can use it to perform transformations on the data or update some fields, but not to exclude records from the result set. If you want to exclude certain records based on some Redis operations, you should do that in the query or manually filter the results after GORM has returned them.