UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = '5APdtq0MHETyAtHp68v9r2sCPflUJZMj3sftWVlDrFg=' 
WHERE 
  key_id = 'f812af3f476050c1fb65cb1751122777d511764cdf7e24e7022e459d2f986661' 
  AND (
    token = '5APdtq0MHETyAtHp68v9r2sCPflUJZMj3sftWVlDrFg=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00036