you could either use ctx.save_for_backward(object) (or) play around with global variables as below.
    def api(self):
        global var_buffer
        if 'var_buffer' not in globals():
            var_buffer = 5 # executed only during first time 
        else:
            print('setter found', var_buffer)
        return 1