开发者

Sessions enabled - do we have to clean them up ourselves?

When we turn sessions on in google app engine like:

// appengine-web.xml
<sessions-enabled>true</sessions-enabled&g开发者_StackOverflowt;

does app engine automatically clean up expired sessions, or do we have to do it ourselves? After turning them on, I see in the datastore that some entries are being generated like _ah_session, I'm wondering if those are them?

Thanks


Yes those are the session entries. Google's app engine documentation includes the following:

The implementation creates datastore entities of the kind _ah_SESSION, and memcache entries using keys with a prefix of _ahs.

(http://code.google.com/appengine/docs/java/config/appconfig.html)

As for cleaning up session data. I found the following 2 discussions:

http://groups.google.com/group/google-appengine-java/browse_thread/thread/4f0d9af1c633d39a http://www.mail-archive.com/google-appengine-java@googlegroups.com/msg01372.html

HTH, Steve


From Cleaning Up Expired Sessions From App Engine Datastore:

You need to configure the cleanup servlet provided by Google to be run regularly. Note: the servlet cleans at most 100 entries at time. Be sure to decide how often do you need this to be called and determine the interval as appropriate to you.

In web.xml:

<web-app...>
  <servlet>
    <servlet-name>_ah_sessioncleanup</servlet-name>
    <servlet-class>com.google.apphosting.utils.servlet.SessionCleanupServlet</servlet-class>
  </servlet>

  <servlet-mapping>
    <servlet-name>_ah_sessioncleanup</servlet-name>
    <url-pattern>/_ah/sessioncleanup</url;-pattern>
  </servlet-mapping>

  <security-constraint>
    <web-resource-collection>
      <web-resource-name>session-cleanup</web-resource-name>
      <url-pattern>/_ah/sessioncleanup</url-pattern>
    </web-resource-collection>
    <auth-constraint>
      <role-name>admin</role-name>
    </auth-constraint>
  </security-constraint>
  ...
</web-app>

And in cron.xml:

<cronentries>
  <cron>
    <url>/_ah/sessioncleanup?clear</url>
    <description>Clean up sessions</description>
    <schedule>every 15 minutes</schedule>
  </cron>
  ...
</cronentries>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜