English 中文(简体)
Scala/Play:将数据留在单一州是否安全?
原标题:Scala/Play: Is it safe to leave data in Singletons?

如同在“世界快乐”中一样。 阁下:

object Application extends Controller {
    var ak = 0
    import views.Application._

    def index = {
        ak = ak + 1
        html.index("Your Scala application is ready!" + ak)
    }

}

每当你复一页时,就加薪。 是否有任何人知道这种行为是我可以依赖的,或者如果是我应该完全避免的? 似乎我会利用它在当地做一些简单的计算,同时避免将数据序列化/传送到细表上。

最佳回答

Play! 设计为stateless webframework I itn t依赖主计长的生命周期处理这一状况。

集装箱很有可能停止并重新启用控制器,特别是在云层基础设施上。

你们应当认真研究其他选择(如你所提到的那样。

网页上的“紧急和闪电范围”栏目(利用一些设施进行切除):

http://www.playframework.org/documentation/1.1.1/controllers

问题回答

暂无回答




相关问题
How to flatten a List of different types in Scala?

I have 4 elements:List[List[Object]] (Objects are different in each element) that I want to zip so that I can have a List[List[obj1],List[obj2],List[obj3],List[obj4]] I tried to zip them and I ...

To use or not to use Scala for new Java projects? [closed]

I m impressed with Twitter and investigating to use Scala for a new large scale web project with Hibernate and Wicket. What do you think about Scala, and should I use it instead of Java? EDIT: And, ...

Why does Scala create a ~/tmp directory when I run a script?

When I execute a Scala script from the command line, a directory named "tmp" is created in my home directory. It is always empty, so I simply deleted it without any apparent problem. Of course, when I ...

Include jar file in Scala interpreter

Is it possible to include a jar file run running the Scala interpreter? My code is working when I compile from scalac: scalac script.scala -classpath *.jar But I would like to be able to include a ...

Scala and tail recursion

There are various answers on Stack Overflow which explain the conditions under which tail recursion is possible in Scala. I understand the limitations and how and where I can take advantage of tail ...

热门标签