I am constructing an API that will use credits to determine if an API call can be made and the credits will be updated after a successful API request.
The simple procedure after an API call is made is:
- Check if user has credits
- If they have credits, perform the API call
- If call was successful, update the user's credits
However, I believe that this would considerably slow down the API due to database locking on update.
What would be a more efficient way of handling this?