您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

京东上生成100万张优惠券算法问题

2024/3/19 18:28:48发布28次查看
京东上生成100万张优惠券,优惠券券号前缀是qa(比如qak001,qa0u767,qajut55,随机的券号),用什么算法能生成100万张不重复的优惠券?这100万张优惠券券号必须存入数据库或缓存中吗?
回复内容: 京东上生成100万张优惠券,优惠券券号前缀是qa(比如qak001,qa0u767,qajut55,随机的券号),用什么算法能生成100万张不重复的优惠券?这100万张优惠券券号必须存入数据库或缓存中吗?
可以参考算法bloom filter
推荐uuid。
function guid(){ if (function_exists('com_create_guid')){ return com_create_guid(); }else{ mt_srand((double)microtime()*10000);//optional for php 4.2.0 and up. $charid = strtoupper(md5(uniqid(rand(), true))); $hyphen = chr(45);// - $uuid = chr(123)// { .substr($charid, 0, 8).$hyphen .substr($charid, 8, 4).$hyphen .substr($charid,12, 4).$hyphen .substr($charid,16, 4).$hyphen .substr($charid,20,12) .chr(125);// } return $uuid; }}
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product