日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

Redis(案例五:Set数据)

發布時間:2023/12/3 数据库 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Redis(案例五:Set数据) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

案例實戰需求之大數據下的用戶畫像標簽去重

介紹

用戶畫像 英文為User Profile,是根據用戶基本屬性、社會屬性、行為屬性、心理屬性等真實信息?抽象出的?個標簽化的、虛擬的?戶模型。“?戶畫像”的實質是對 “?”的數字化。應?場景有很多,比如個性化推薦、精準營銷、?融?控、精細化運營等等, 舉個例?來理解?戶畫像的實際應?價值,我們經常??機?購,淘寶??的千?千?通過“標簽 tag”來對?戶的多維度特征進?提煉和標識,那每個?的?戶畫像就需要存儲,set集合就適合去重?戶畫像不?針對某個?,也可以某??群或?業的畫像,利?redis可以很好的去重

@SpringBootTest class XdclassRedisApplicationTests {@Autowiredprivate RedisTemplate redisTemplate;@Testpublic void userProfile(){BoundSetOperations operations = redisTemplate.boundSetOps("user:tags:1");operations.add("car","student","rich","dog","guangdong","rich");Set<String> set1 = operations.members();System.out.println(set1);operations.remove("dog");Set<String> set2 = operations.members();System.out.println(set2);} }

社交應用里面的知識,關注、粉絲、共同好友案例

@SpringBootTest class XdclassRedisApplicationTests {@Autowiredprivate RedisTemplate redisTemplate;/*** 社交應用*/@Testpublic void testSocial(){BoundSetOperations operationsLW = redisTemplate.boundSetOps("user:lw");operationsLW.add("A","B","C","D","E");System.out.println("老王的粉絲:"+operationsLW.members());BoundSetOperations operationsXD = redisTemplate.boundSetOps("user:xd");operationsXD.add("A","B","F","G","H","K","J","W");System.out.println("小d的粉絲:"+operationsXD.members());//差集Set lwSet = operationsLW.diff("user:xd");System.out.println("老王的專屬用戶:"+lwSet);//差集Set xdSet = operationsXD.diff("user:lw");System.out.println("小D的專屬用戶:"+xdSet);//交集Set interSet = operationsLW.intersect("user:xd");System.out.println("同時關注了兩個人的用戶:"+interSet);//并集Set unionSet = operationsLW.union("user:xd");System.out.println("兩個人的并集:"+unionSet);//判斷A用戶是不是老王的粉絲boolean flag = operationsLW.isMember("A");System.out.println("A用戶是不是老王的粉絲:"+flag);} }

總結

以上是生活随笔為你收集整理的Redis(案例五:Set数据)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。