Package com.google.appengine.api.memcache

Examples of com.google.appengine.api.memcache.MemcacheService


    return chapters;
  }

  public List<List<Chapter>> getChaptersGroupedByCountry() {
    MemcacheService ms = MemcacheServiceFactory.getMemcacheService();

    if (!ms.contains(CHAPTERS_GROUPED_BY_COUNTRY_MEMCACHE_KEY)) {
      List<Chapter> chapters = chapterDao.getChaptersOrderedByCountry();
      if (chapters == null) {
        return null;
      }

      List<List<Chapter>> groups = new ArrayList<List<Chapter>>();
      List<Chapter> group = new ArrayList<Chapter>();
      String country = chapters.get(0).getCountry();

      for (Chapter chapter : chapters) {
        if (!chapter.getCountry().equals(country)) {
          groups.add(group);
          group = new ArrayList<Chapter>();
          country = chapter.getCountry();
        }

        group.add(chapter);
      }

      groups.add(group);

      ms.put(CHAPTERS_GROUPED_BY_COUNTRY_MEMCACHE_KEY, groups);
    }
   

    return (List<List<Chapter>>) ms.get(
        CHAPTERS_GROUPED_BY_COUNTRY_MEMCACHE_KEY);
  }
View Full Code Here


    return (List<List<Chapter>>) ms.get(
        CHAPTERS_GROUPED_BY_COUNTRY_MEMCACHE_KEY);
  }

  public void storeChapter(Chapter chapter) {
    MemcacheService ms = MemcacheServiceFactory.getMemcacheService();

    chapterDao.storeChapter(chapter);

    ms.delete(CHAPTERS_MEMCACHE_KEY);
    ms.delete(ACTIVE_CHAPTERS_MEMCACHE_KEY);
    if (chapter.getId() != null) {
      ms.delete(CHAPTER_MEMCACHE_KEY + chapter.getId());
    }
    ms.delete(CHAPTER_COUNT_MEMCACHE_KEY);
    ms.delete(CHAPTERS_GROUPED_BY_COUNTRY_MEMCACHE_KEY);
  }
View Full Code Here

  @Autowired
  private JdoLocationDao locationDao;

  public List<Location> getLocations() {
    MemcacheService ms = MemcacheServiceFactory.getMemcacheService();

    if (!ms.contains(LOCATIONS_MEMCACHE_KEY)) {
      ms.put(LOCATIONS_MEMCACHE_KEY, locationDao.getLocations());
    }

    return (List<Location>) ms.get(LOCATIONS_MEMCACHE_KEY);
  }
View Full Code Here

    return (List<Location>) ms.get(LOCATIONS_MEMCACHE_KEY);
  }

  public void incrementOrStoreLocation(Double latitude, Double longitude) {
    MemcacheService ms = MemcacheServiceFactory.getMemcacheService();

    locationDao.incrementOrStoreLocation(latitude, longitude);

    ms.delete(LOCATIONS_MEMCACHE_KEY);
  }
View Full Code Here

  private GoogleMapsService mapsService = new GoogleMapsService("ABQIAAAAVcC1CwycXgD607vgA6-JWRQsQrdbh9VYytIyhTexABq-UD140xRDqWhEuEAiRVhjGXFCXv8ybo6Mfw");

  public void doGet(HttpServletRequest request, HttpServletResponse response)
      throws IOException {
    response.setContentType("text/plain");
    MemcacheService ms = MemcacheServiceFactory.getMemcacheService();
    ms.clearAll();

    String chapterId = request.getParameter("id");
    Chapter chapter = retrieveChapter(chapterId);

    if (chapter == null) {
View Full Code Here

@SuppressWarnings("serial")
public class ClearMemcacheServlet extends HttpServlet {

  public void doGet(HttpServletRequest request, HttpServletResponse response)
      throws IOException {
    MemcacheService ms = MemcacheServiceFactory.getMemcacheService();
    ms.clearAll();

    response.sendRedirect("/");
  }
View Full Code Here

  public Event getEvent(Long id) {
    return eventDao.getEvent(id);
  }

  public List<Event> getEvents() {
    MemcacheService ms = MemcacheServiceFactory.getMemcacheService();

    if (!ms.contains(EVENTS_MEMCACHE_KEY)) {
      ms.put(EVENTS_MEMCACHE_KEY, getEvents(false));
    }

    return (List<Event>) ms.get(EVENTS_MEMCACHE_KEY);
  }
View Full Code Here

  public List<Event> getPastEvents(Long chapterId) {
    return eventDao.getPastEvents(chapterId);
  }

  public void storeEvent(Event event) {
    MemcacheService ms = MemcacheServiceFactory.getMemcacheService();

    eventDao.storeEvent(event);

    ms.delete(EVENTS_MEMCACHE_KEY);
  }
View Full Code Here

  @Autowired
  private CountryDao countryDao;

  public List<Country> getCountries() {
    MemcacheService ms = MemcacheServiceFactory.getMemcacheService();

    if (!ms.contains(COUNTRIES_MEMCACHE_KEY)) {
      ms.put(COUNTRIES_MEMCACHE_KEY, countryDao.getCountries());
    }

    return (List<Country>) ms.get(COUNTRIES_MEMCACHE_KEY);
  }
View Full Code Here

    return (List<Country>) ms.get(COUNTRIES_MEMCACHE_KEY);
  }

  public void storeCountry(Country country) {
    MemcacheService ms = MemcacheServiceFactory.getMemcacheService();

    countryDao.storeCountry(country);
    ms.delete(COUNTRIES_MEMCACHE_KEY);
  }
View Full Code Here

TOP

Related Classes of com.google.appengine.api.memcache.MemcacheService

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.