class ExampleController < ApplicationController
def getAPI
#retrieve and process data from API
end
end
How can I avoid that the controller action gets executed simultaneous? Would a class variable work?
class ExampleController < ApplicationController
@@in_progress = false
def getAPI
render and return if @@in_progress
@@in_progress = true
#retrieve and process data from API
@@in_progress = false
end
end
Are class variables persistent even if the applications runs with multiple processes of e.g. passenger. Is this a good idea at all?
Will this work if multiple users request the same controller action or does it only avoid simultaneous execution for one user?