Certain things can be stateless, but if you use any of the form binding etc etc (basically, most of the stuff in lift that creates function closures) then you will be using state.
What is your use case for not needing a session at all? Depending upon what you want to do, it is possible. Generally speaking though, unless your like foursquare size or whatever, its a premature optimisation... Sessions != Evil all the time.
Cheers, Tim
> --
> You received this message because you are subscribed to the Google Groups "Lift" group.
> To post to this group, send email to lif...@googlegroups.com.
> To unsubscribe from this group, send email to liftweb+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.
>
>
Hi all,
I'm new to lift and just started using lift 2.0. To get started, I
decided to create a very simple page: it only depends on the time of
the server and then shows you whether it's a holiday or not.
I started with the lift sbt project tarball and got that working
quickly. I then started to remove unneeded extras from src/main/scala/
bootstrap/liftweb/Boot.scala. I'm now left with only the following
source blow.
Dispite all this, using jetty I still get a jsessionID and (what is
actually pissing me off a bit) it will rewrite urls to insert the
jsessionid get parameter if I don't accept the cookies.
How can I stop the server from trying to initiate a session?
--
You received this message because you are subscribed to the Google Groups "Lift" group.
To post to this group, send email to lif...@googlegroups.com.
To unsubscribe from this group, send email to liftweb+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.
Thank you all for the quick and direct replies.
The main reason I wanted to disable sessions is because I don't know how
the expired sessions are cleaned up and as a precaution the would be
better left out for my first ever lift deployment.
Knowing what I know now, I'm going to try to get my first lift site ever
online!
Greets,
Bram
I think David recently added some hooks for Harry that allow one to watch session creation/destruction in some detail, if you're interested.
-Ross
Hi all,
Thank you all for the quick and direct replies.
The main reason I wanted to disable sessions is because I don't know how the expired sessions are cleaned up and as a precaution the would be better left out for my first ever lift deployment.
object SessionInfoDumper extends LiftActor with Loggable {private var lastTime = millis
private def cyclePeriod = 1 minuteimport net.liftweb.example.lib.SessionCheckerprotected def messageHandler ={case SessionWatcherInfo(sessions) =>if ((millis - cyclePeriod) > lastTime) {lastTime = millisval rt = Runtime.getRuntimert.gc
RuntimeStats.lastUpdate = timeNowRuntimeStats.totalMem = rt.totalMemoryRuntimeStats.freeMem = rt.freeMemoryRuntimeStats.sessions = sessions.sizeval percent = (RuntimeStats.freeMem * 100L) / RuntimeStats.totalMem// get more aggressive about purging if we're// at less than 35% free memoryif (percent < 35L) {SessionChecker.killWhen /= 2Lif (SessionChecker.killWhen < 5000L)SessionChecker.killWhen = 5000LSessionChecker.killCnt *= 2} else {SessionChecker.killWhen *= 2Lif (SessionChecker.killWhen >SessionChecker.defaultKillWhen)SessionChecker.killWhen = SessionChecker.defaultKillWhenval newKillCnt = SessionChecker.killCnt / 2if (newKillCnt > 0) SessionChecker.killCnt = newKillCnt}
val dateStr: String = timeNow.toStringlogger.info("[MEMDEBUG] At " + dateStr + " Number of open sessions: " + sessions.size)logger.info("[MEMDEBUG] Free Memory: " + pretty(RuntimeStats.freeMem))logger.info("[MEMDEBUG] Total Memory: " + pretty(RuntimeStats.totalMem))logger.info("[MEMDEBUG] Kill Interval: " + (SessionChecker.killWhen / 1000L))logger.info("[MEMDEBUG] Kill Count: " + (SessionChecker.killCnt))}}
private def pretty(in: Long): String =if (in > 1000L) pretty(in / 1000L) + "," + (in % 1000L)else in.toString}
object SessionChecker extends Function2[Map[String, SessionInfo],SessionInfo => Unit, Unit] with Logger{def defaultKillWhen = 180000L// how long do we wait to kill single browsers@volatile var killWhen = defaultKillWhen
@volatile var killCnt = 1
def apply(sessions: Map[String, SessionInfo],destroyer: SessionInfo => Unit): Unit = {val cutoff = millis - 180000Lsessions.foreach {case (name, si @ SessionInfo(session, agent, _, cnt, lastAccess)) =>if (cnt <= killCnt && lastAccess < cutoff) {info("Purging "+agent)destroyer(si)}}}}
SessionMaster.sessionCheckFuncs = SessionMaster.sessionCheckFuncs ::: List(SessionChecker)SessionMaster.sessionWatchers = SessionInfoDumper :: SessionMaster.sessionWatchers
Sent from my iPhone