• 网站每日UV数据指标去重统计


    package com.iexecloud.cloud.casemanager;

    import redis.clients.jedis.Jedis;

    import java.text.SimpleDateFormat;
    import java.util.Date;

    public class UVDemo {

    private Jedis jedis=new Jedis("127.0.0.1");
    /**
    * 添加一次用户访问记录
    * @param userid
    */
    public void addaUserAccess(long userid){
    SimpleDateFormat date = new SimpleDateFormat("yyyy-MM-dd");
    String today = date.format(new Date());

    jedis.sadd("user_access_::"+today,String.valueOf(userid));
    }


    public Long getUV(){
    SimpleDateFormat date = new SimpleDateFormat("yyyy-MM-dd");
    String today = date.format(new Date());
    return jedis.scard("user_access_::"+today);
    }

    public static void main(String[] args) {
    UVDemo uvDemo = new UVDemo();
    for (int i = 0; i <100 ; i++) {
    long userid=i+1;
    for (int j = 0; j <10 ; j++) {
    uvDemo.addaUserAccess(userid);
    }
    }
    Long uv = uvDemo.getUV();
    System.out.println("当日的UV为:"+uv);
    }















    }
  • 相关阅读:
    Django(一)
    web 框架
    图片
    day16
    day 15
    day14 HTML CSS
    day12
    day11
    python IO多路复用,初识多线程
    python socket
  • 原文地址:https://www.cnblogs.com/q1359720840/p/14631708.html
Copyright © 2020-2023  润新知