Giter VIP home page Giter VIP logo

Comments (12)

xman01111 avatar xman01111 commented on July 21, 2024 1

嗯 是的 在csredis内部处理的话这样确实不好 需要的话自己可以用拓展类实现就可以实现 之前没有注意直接取就错了

from csredis.

2881099 avatar 2881099 commented on July 21, 2024

贴出代码,我帮你看看

from csredis.

xman01111 avatar xman01111 commented on July 21, 2024
    [HttpGet]
    public ActionResult GetData()
    {
        List<object> xdata = new List<object>();
        List<object> ydata = new List<object>();
        int max=1;
        var listdata111 = RedisHelper.LPop("keyWWHRP:dfa4e36d-daed-4c9b-820f-7a0933dfc2b1");
        var list= RedisHelper.Keys("keyWWHRP:*").ToList();
        foreach (var item in list)
        {
          var len = RedisHelper.LLen(item);
          var listdata=RedisHelper.LRang(item,0, 7);
          
        }

        return Json(list);
    }

from csredis.

xman01111 avatar xman01111 commented on July 21, 2024

这个键里面的8条数据 但是无论是用LLen LPOP 还是LRang 都获取不了

from csredis.

2881099 avatar 2881099 commented on July 21, 2024

push在哪里做的,试试把链接串里面prefix设置成空

from csredis.

2881099 avatar 2881099 commented on July 21, 2024

prefix 是 key 前缀参数,除非也是用RedisHelper.LPush,get 的时候实际会取 prefix + key

from csredis.

xman01111 avatar xman01111 commented on July 21, 2024
                //获取当前领取的数量
                string Num = RedisHelper.Get(PrefixKeyHelper.GetRedPacketIncrement() + redpacket.Id);
                if (Num == null || Num.ToInt() < redpacket.num)
                {
                    //自增红包数
                    RedisHelper.Increment(PrefixKeyHelper.GetRedPacketIncrement() + redpacket.Id);
                    //更新红包缓存数据              
                    RedisHelper.Set(PrefixKeyHelper.GetRedPacketPK() + redpacket.Id, redpacket.Serialize());
                    //创建已领取红包记录Model
                    Create();
                    //写入待更新红包表数据库队列
                    RedisHelper.LPush(PrefixKeyHelper.GetWaitWriteRedPacket() + redpacket.Id, redpacket.Serialize());
                    //写入红包领取记录缓存队列
                    RedisHelper.LPush(PrefixKeyHelper.GetWaitWriteHadGetRedPacket() + redpacket.Id, hadGetRedPacket.Serialize());
                    result.Status = (int)MRC.Data.Enum.EnumGetRedPacketStatus.GetOK;
                }
                else
                {
                    result.Status = (int)MRC.Data.Enum.EnumGetRedPacketStatus.Over;
                }

设置的时候是采用 自己设定的前缀+key的形式

    /// <summary>
    /// 红包表前缀
    /// </summary>
    private static  readonly string RedPacketPK= "RP:";

    /// <summary>
    /// 红包领取自增计数
    /// </summary>
    private static readonly string RedPacketIncrement = "RP:Ict:";

    /// <summary>
    /// 已领红包前缀
    /// </summary>
    private static readonly string HadGetRedPacketPK = "HRP:";

    /// <summary>
    /// 已领红包待处理队列
    /// </summary>
    private static readonly string WaitWriteHadGetRedPacket = "WWHRP:";

    /// <summary>
    /// 红包表更新待处理队列
    /// </summary>
    private static readonly string WaitWriteRedPacket = "WWRP:";

from csredis.

xman01111 avatar xman01111 commented on July 21, 2024

我知道了 用Keys获取 列表的时候 会带有key前缀 这个key应该是redishelper加上的 去掉就行了 Thank

from csredis.

xman01111 avatar xman01111 commented on July 21, 2024

原:
var listdata111 = RedisHelper.LPop("keyWWHRP:dfa4e36d-daed-4c9b-820f-7a0933dfc2b1");
现在:
var listdata111 = RedisHelper.LPop("WWHRP:dfa4e36d-daed-4c9b-820f-7a0933dfc2b1");

from csredis.

2881099 avatar 2881099 commented on July 21, 2024

是的

"127.0.0.1:6371,password=123,defaultDatabase=11,poolsize=10,ssl=false,writeBuffer=10240,prefix=key前辍"

prefix参数留空的话,没有你说的问题。否则,所有大部分方法操作(注释有标明),都会附带前辍,从而导致少部分冲突。

from csredis.

2881099 avatar 2881099 commented on July 21, 2024

考虑到99%写代码时候,自己加前辍的繁琐,所以增加了prefix参数配置。

from csredis.

2881099 avatar 2881099 commented on July 21, 2024

也可以 RedisHelper.Keys("keyWWHRP:*") 循环的时候,手工处理前辍。
csredis内部不敢处理keys命令返回的前辍,怕引起很深的坑。

from csredis.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.