input: Write a function to optimize a Flask application for efficient performance. The function should configure the Flask app to use Redis for caching session and query performance, uWSGI for Python applications, gunicorn as WSGI server, Flask-Compress for compression, use global variables where applicable, avoid direct SQL queries and use model methods instead, use query parameters in URLs, and use thread-local objects for performance. The function should return the configured Flask app.
  from flask import Flask, request, jsonify
  import redis
  from flask_compress import Compress
  
  def optimize_flask_app():
      app = Flask(__name__)
      Compress(app)
  
      @app.route('/api/<endpoint>', methods=['GET', 'POST'])
      def process_request(endpoint):
          # Performance optimization code here
          pass
  
      return app
  
  assert optimize_flask_app().__name__=="__main__"
  assert optimize_flask_app().config == {}
  assert optimize_flask_app().url_map.strict_slashes == True
  assert hasattr(optimize_flask_app(), 'extensions')
  assert 'compress' in optimize_flask_app().extensions
output: 
  from flask import Flask, request, jsonify
  import redis
  from flask_compress import Compress
  
  def optimize_flask_app():
      app = Flask(__name__)
      app.config['SESSION_TYPE'] = 'redis'
      app.config['SESSION_REDIS'] = redis.StrictRedis(host='localhost', port=6379, db=0)
      Compress(app)
  
      @app.route('/api/<endpoint>', methods=['GET', 'POST'])
      def process_request(endpoint):
          # Example of using query parameters
          query_param = request.args.get('param')
          # Example of using model methods instead of direct SQL queries
          result = some_model_method(query_param)
          return jsonify(result)
  
      return app
  