I am new to AOP, Sorry, if this question is too obvious. I am using aspectj in my application to save data in cache.
For all save methods(which saves data in DB), I am using advice @AfterReturning and saving result to cache(Redis), after method returns successfully. So, my save method has to wait till data is saved in cache too.
I don't want my save method to wait till data is saved in redis cache. I know I can do this by creating my own async executor using runnable, but I want to use AOP. So, is there anyway I can make this AOP advice run Asynchronously?
No, each advice runs in the same thread as the code it intercepts, otherwise you might have other problems due to concurrency. But you do not want AOP to introduce problems, rather to solve them. ;-)
Having said that, nothing keeps you from spawning off a new thread from within an advice, does it?