⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sessioncache.java

📁 Auctions are among the oldest economic institutions in place. They have been used since antiquity to
💻 JAVA
字号:
import java.util.Hashtable;
import java.util.Enumeration;

class SessionCache implements  Runnable {

    private Hashtable sessionCache;
    private long flush;
    private Thread reaper;

    SessionCache (long flush) {
       this.flush=flush;
       sessionCache=new Hashtable (100);
       reaper=new Thread (this);
       reaper.setPriority (Thread.MIN_PRIORITY);
       reaper.start();
    }

    public void run() {
        while (true) {
           try {
               Thread.sleep (flush);
               Enumeration sessions;
               Session s;
               long expire;
               expire=System.currentTimeMillis();
               sessions=sessionCache.elements();
               while ( sessions.hasMoreElements() ) {
                   s=(Session)sessions.nextElement();
                   if ( expire >= s.getExpires()) {
                       sessionCache.remove (s.key());
                   }
               }
           } catch (Exception e) {
               return;
           }
       }
    }

    Session put (Session s) {
       return (Session)sessionCache.put (s.key(), s);
    }

    Session get (String key) {
       return (Session)sessionCache.get (key);
    }

    Enumeration elements () {
       return sessionCache.elements();
    }

    Enumeration keys () {
       return sessionCache.keys();
    }

    void remove (Session s) {
       sessionCache.remove (s.key());
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -