3

I'm novice in Play framework,

We said that Play 2 is fully RESTful - there is no Java EE session per connection. However, we can save data in different ways: Session, Flash or Cache!

Does not exist any contradiction?! or I misunderstood things?!

Could someone explain to me?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Momog
  • 567
  • 7
  • 27

1 Answers1

11

Session and Flash data are stored on the client itself, in a cookie. They are sent to the server on each request, in fully stateless architecture. If you have an pool with 3 servers, any of them will be able to process the request.

The cache is a temporary data storage. It does not certify that the data you insert will be available when you need them. Consequently, for each cached data, the server must be able to retrieve them, from a database generally.

In this way, the cache doesn't need to be shared between each server, according to the stateless architecture.

Julien Lafont
  • 7,869
  • 2
  • 32
  • 52
  • I've always wondered: how come Play keeps working when I disable my cookies (I can still retrieve/store data in the `session` across multiple requests), do you know this? – Aerus Jun 04 '13 at 17:57
  • You should verify your test, session mechanism cannot work without cookies (just tested with https://gist.github.com/studiodev/af045afc2240f79aa3b6) – Julien Lafont Jun 04 '13 at 21:16
  • I tested the gist you posted and you're absolutely right! (and sadly this means I turned in a project for uni with a few major flaws in, although not in code written by me but the tests should have pointed out those flaws) – Aerus Jun 04 '13 at 21:55