Example usage for org.apache.shiro.cache Cache values

List of usage examples for org.apache.shiro.cache Cache values

Introduction

In this page you can find the example usage for org.apache.shiro.cache Cache values.

Prototype

public Collection<V> values();

Source Link

Document

Returns a view of all of the values contained in this cache.

Usage

From source file:org.cast.go.message.web.WebSocketController.java

License:Apache License

/**
 * session?/* w  ww.  j  a  v  a 2  s.  c o  m*/
 * @return
 */
@MessageMapping("/online")
public void online(User user) {
    Cache cache = ehCacheManager.getCache(Common.ACTIVE_SESSIONS_CACHE_NAME);
    Collection<SimpleSession> sessions = cache.values();
    for (SimpleSession s : sessions) {
        MyRealm.ShiroUser shiroUser = (MyRealm.ShiroUser) s.getAttribute("shiroUser");
        if (user.getUsername().equals(shiroUser.getUsername())) {
            s.setLastAccessTime(new Date());
        }
    }

}