Recache will not help you avoid duplicates.
You are trying to increment a counter in Lotus Notes to create a unique sequential identifier for documents. This is a problem that has been discussed many times, by many people, for at least 20 years. You can find good information here in StackOverflow and in various other forums, blogs, and articles. The two approaches that work are
- Store the last counter value in a config doc, and use document locking to assure that you don't have two users accessing and updating it at the same time.
- Do not set the counter variable directly in user code. Write your code to put a "pending" value in the field, and rely on a scheduled or triggered background agent that runs on only one server to set the final value. (Since the Agent Manager guarantees that only one agent can run at a time in one database, you will not have conflicts.)
- Don't use a sequential counter for your identifier. Use the
@Unique
function instead. Documents will have a unique code instead of a unique number.