I'm using the Java API.  In my app, I store (only) the ISBN's of a
series of books.  When I load the books, my service goes to Amazon and
retrieves the rest of the information about the book from their web
service.  Then I display all the books on a page.

My service uses the JCache API, with a static attribute to represent
the cache.  The (pseudo) code below is roughly analogous to what I
actually do:

public class AmazonBookService {
  private static Cache cache;

  static {
     int secs = // expiration limit
     cache = // get the factory, initialize the cache with expiration
limit
  }

  public Book[] getBooks() {
      // use a DAO to get the ISBNs from the datastore -- happens
every request
      // initialize results array
      // for each ISBN:
          // if book is in cache, add it to results
          // if not, fetch data from Amazon, build book, and add it to
cache and the results
      // }
      // return all the books
  }
}

When I deploy the service, it seems to work, but most of the time when
I refresh a web page it still take a long time.

My questions are:

1. Is this the right way to use the cache?
2. How can I check to see if it's working?
3. Is there a way I can send all the book requests to Amazon
simultaneously?

Thanks,

Ken Kousen
[email protected]

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to