2

I have a query result in spring data Like :

public interface user extends extends CrudRepository<UserRegistration, Long> {
@Query(value="select ur from UserRegistration ur where "
        + " ur.location.id IN ?1 AND"
        + " ur.event.id IN ?2")
        public List<UserRegistration> getUsersBylocationAndEvent(long[] locationList, long[] eventList);
}

and use this method in service implementation as

public class userServiceImpl implements userService{
@Autowired
UserRegistrationRepository userRegistrationRepository;

@Override
public List<UserRegistration> getUserRegistarationByEventAndLocation(long[] locationList, long[] eventList, int checkInFlag, Date checkInDate, int checkOutFlag, Date checkOutDate) {
    List<UserRegistration> userRegistrationList = userRegistrationRepository.getUserRegByLocationIdsAndEvenIds(locationList, eventList);

    return userRegistrationList;
}}

And I used this method "getUserRegistarationByEventAndLocation()" in multiple webServices, so I want to cache the result when first webservice called in list and can use this list in other webService.

1
  • make list a member variable and check if content exists. not sure if this is what you are looking for Commented May 31, 2017 at 10:15

1 Answer 1

1

we can use the @Cacheable annotation. it might be helpful

 @Cacheable(value="UserRegistration")
  List<UserRegistration> getUserRegByLocationIdsAndEvenIds(locationList, eventList);
  {

  }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.