当前位置:网站首页>Determine whether the user is entering a page for the first time

Determine whether the user is entering a page for the first time

2022-06-25 07:56:00 On procedural retreat

 Usage of this method : Determine whether the user is entering this page for the first time 

The main approach : take key Values stored in MemCache In cache , According to the user userId Search for value value

According to return false/true, To determine whether it is the first time to enter

The specific code is as follows :

int userID = 20170812; final String key = "key"; boolean has = MemCacheHelper.keyExists(key); boolean exsit = false; if (!has) { Map<Integer, Integer> userTabs = new HashMap<Integer, Integer>(1); userTabs.put(userID, 1); MemCacheHelper.bulidCache(key, userTabs, new Date(-1)); } else { Map<Integer, Integer> userTabs = (HashMap<Integer, Integer>)MemCacheHelper .getCache(key); if (userTabs != null && userTabs.size() > 0) { if (!userTabs.containsKey(userID)) { userTabs.put(userID, 1); MemCacheHelper.replace(key, userTabs); } else { exsit = true; } } } if(exsit){ // First entry  }else { // Enter after the second time  }


原网站

版权声明
本文为[On procedural retreat]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/176/202206250547109725.html