English feliratok

← Using Memcache for Announcements - Developing Scalable Apps with Java

Beágyazókód kérése
4 Languages

Showing Revision 5 created 05/24/2016 by Udacity Robot.

  1. There's really not much you need to do to get
  2. your application to use Memcache to save and get entity data,
  3. if you're using Objectify. But it's still useful to know
  4. how to write code to use Memcache. So we're going to use
  5. Memcache to save and get announcements, about conferences that are
  6. nearly sold out. You can imagine, for example, that your web
  7. app might display a banner ad to encourage people to
  8. sign up. For conferences that are nearly sold out. There might
  9. be other things you want to announce on your website, too.
  10. Maybe if you get a special speaker for a particular conference.
  11. Or you want to announce a special promotion. But for the
  12. sake of simplicity, we're just going to create announcements that conferences
  13. are nearly sold out. Because the goal here is to learn
  14. how to use Memcache. Announcements though, are a good example of
  15. the kind of thing that you might want to save in
  16. Memcache, without saving them to the Datastore. If the announcement gets evicted
  17. from Memcache, there's no loss of real data, and it
  18. doesn't really matter. No business transactions are affected, no one loses
  19. their place at a conference. And the next announcement will likely
  20. come along very soon anyway. Announcements are very transient, and don't
  21. need to be saved for the long term and they
  22. don't need to be backed up. So, they're perfect candidates to
  23. be saved in Memcache, and only in Memcache. They don't need
  24. to into the Datastore, that way you get all your announcements
  25. without using any quota. So, you're going to
  26. adding the announcement class to your project. It's
  27. a very simple class, we need it because
  28. n point functions can't return string objects. So
  29. they're going to put the text for the announcement,
  30. in the message field. Note that this class
  31. is not annotated as our entity. We don't
  32. want to save the announcements in the data store.