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:

  1. Check if user has credits
  2. If they have credits, perform the API call
  3. 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?

  • The API call, itself, may be more costly than the database call. – Rick James Aug 12 at 16:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.