当前位置:网站首页>.net operation redis sorted set ordered set
.net operation redis sorted set ordered set
2022-07-26 10:34:00 【Miners learn programming】
One 、sorted set An overview of ordered sets
Redis An ordered set is the same as a set string Collection of type elements , And duplicate members are not allowed .
The difference is that each element is associated with a double Score of type .redis It's the scores that sort the members of a collection from small to large .
Members of an ordered set are unique , But fractions (score) But it can be repeated .
Collections are implemented through hash tables , So add the , Delete , The complexity of searching is O(1). The maximum number of members in the collection is 232 - 1 (4294967295, Each collection can store 40 More than 100 million members ).
Two 、 Use scenarios
Use scenarios , Do service registration at discovery , Luck draw , Current limiting , Rankings, etc
3、 ... and 、.NET operation
1、 Basic operation
string zsett_key = "kgxk_zset";
// Add one kye If there is the same value , Will be replaced ( Cover ) go in , Will not be retained because of scores
client.AddItemToSortedSet(zsett_key, "cc", 33);
client.AddItemToSortedSet(zsett_key, "cc", 44);
client.AddItemToSortedSet(zsett_key, "cc", 22);
Console.WriteLine("ok");
// Get current value Result
Console.WriteLine(client.GetItemIndexInSortedSet(zsett_key, "cc"));
// Batch operation multiple key , For more than one key assignment 1
client.AddRangeToSortedSet(zsett_key, new List<string>() { "a", "b" }, 1);
foreach (var item in client.GetAllItemsFromSortedSet(zsett_key))
{
Console.WriteLine(item);
}
2、 Get the value according to the subscript range
client.AddItemToSortedSet(" Shu Kingdom ", " Liu bei ", 5);
client.AddItemToSortedSet(" Shu Kingdom ", " Guan yu ", 2);
client.AddItemToSortedSet(" Shu Kingdom ", " Zhang Fei ", 3);
client.AddItemToSortedSet(" State of Wei ", " Liu bei ", 5);
client.AddItemToSortedSet(" State of Wei ", " Guan yu ", 2);
client.AddItemToSortedSet(" Shu Kingdom ", " Zhang Fei ", 3);
// obtain key It is the subscript of Shu 0, To 2
IDictionary<String, double> Dic = client.GetRangeWithScoresFromSortedSet(" Shu Kingdom ", 0, 2);
foreach (var r in Dic)
{
Console.WriteLine(r.Key + ":" + r.Value);
}
var DicString = client.StoreIntersectFromSortedSets("2", " Shu Kingdom ", " State of Wei ");
var ss = client.GetAllItemsFromSortedSet("2");
边栏推荐
- Perfect / buffer motion framework in sentence parsing JS (for beginners)
- equals与==的区别
- 结构体操作报错:Segmentation fault (core dumped)
- Kaptcha image verification code integration
- [Halcon vision] Fourier transform of image
- What is wrong about the description of function templates (how to solve link format errors)
- MLX90640 红外热成像仪测温传感器模块开发笔记(六)
- 【杂谈】Error loading psycopg2 module :No module named psycopg2
- Analyze the hybrid construction objects in JS in detail (construction plus attributes, prototype plus methods)
- [Halcon vision] software programming ideas
猜你喜欢
【机器学习小记】【风格迁移】deeplearning.ai course4 4th week programming(tensorflow2)
Dynamically determine file types through links
Application of.Net open source framework in industrial production
js下载文件,FileSaver.js导出txt、excel文件
[Halcon vision] Fourier transform of image
Comparison of packet capturing tools fiddler and Wireshark
js翻页、kkpager.js翻页
Review of database -- 1. Overview
404页面和路由钩子
Review of database -- 3. SQL language
随机推荐
Inheritance method of simplified constructor (II) - class inheritance in ES6
Li Kou daily question 917
函数模板参数(函数参数在哪)
【C#语言】LINQ概述
Draco developed by Google and Pixar supports USD format to accelerate 3D object transmission & lt; Forward & gt;
【C#语言】具名类型和匿名类型
数据库函数
json-c库的简单使用——将json文件转换为struct.
vscode上使用anaconda(已经配置好环境)
[Halcon vision] morphological expansion
同步方法中不使用asyncTask<T> 修饰和await获取异步返回值(同步方法中调用异步方法)
Okaleido ecological core equity Oka, all in fusion mining mode
Agenda express | list of sub forum agenda on July 27
Application of.Net open source framework in industrial production
L2-005 集合相似度(vector、set求并交集)
PLC overview
[leetcode每日一题2021/8/30]528. 按权重随机选择【中等】
12 复制对象时勿忘其每一个成分
[Halcon vision] software programming ideas
L2-005 set similarity (intersection of vector and set)