Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Difference between Session and Cache  RSS feed

 
aishwarya lakshmi
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Could you explain what is the differnece between storing the object in session and Cache.
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 37230
519
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A session is specific to one user. A cache is generally shared across the whole application (all users.)
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Plus the session is a standard, default JEE thing provided by the container. Caches are more often developer-controlled, are generally more configurable, and can live at several different levels of an application.
 
Lino Fonseca
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A session would be used to track a user across the site. For example, once a user logs in then the roles and permissions associated with him can be stored in the session. For a shopping site, you may want to associate a shopping cart id with his session.

A cache on the other hand would be used to make certain frequently used resources quickly available rather than having to be loaded on each request. This would reduce the request and response time for a call.

Hope this helps.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!