May I ask in Ristretto how can I sync with Database?

Ristretto can’t do this. Even if the interfaces to execute some function on Sets and Deletes existed, you’d still need to provide the logic for those functions. Specifically, Ristretto is a key-value cache and Postgres is a SQL database. Ristretto cannot do the translation between these two formats on its own.