当前位置:网站首页>.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");
边栏推荐
猜你喜欢

【Halcon视觉】编程逻辑

链式方法调用的事务问题剖析

数据分析入门 | kaggle泰坦尼克任务(一)—>数据加载和初步观察
![[Halcon vision] array](/img/29/905d93795a24538fded18d2d377e52.png)
[Halcon vision] array
![[Halcon vision] threshold segmentation](/img/1c/e2463a796f99804a55680b69e714a6.png)
[Halcon vision] threshold segmentation

equals与==的区别

Introduction to data analysis | kaggle Titanic mission (I) - > data loading and preliminary observation

议程速递 | 7月27日分论坛议程一览

干货likeshop外卖点餐系统开源啦100%开源无加密
![[Halcon vision] affine transformation](/img/f1/32284c71e78e6eea390fdb6058ba0f.png)
[Halcon vision] affine transformation
随机推荐
Review of database -- 1. Overview
cavans实现静态滚动弹幕
.NET操作Redis List列表
What if MySQL can't get in
Agenda express | list of sub forum agenda on July 27
[Halcon vision] polar coordinate transformation
结构体操作报错:Segmentation fault (core dumped)
【Halcon视觉】软件编程思路
关于函数模板描述错误的是(链接格式错误怎么解决)
[Halcon vision] morphological expansion
.NET操作Redis sorted set有序集合
【Halcon视觉】极坐标变换
vscode上使用anaconda(已经配置好环境)
Function templates and non template functions with the same name cannot be overloaded (definition of overloads)
[Halcon vision] programming logic
STM32 阿里云MQTT esp8266 AT命令
MLX90640 红外热成像仪测温传感器模块开发笔记(六)红外图像伪彩色编码
少了个分号
[leetcode每日一题2021/2/14]765. 情侣牵手
String null to empty string (what does empty string mean)