Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RedisHelper.ZScore方法报错 #275

Open
caoxuanyu opened this issue Mar 24, 2020 · 8 comments
Open

RedisHelper.ZScore方法报错 #275

caoxuanyu opened this issue Mar 24, 2020 · 8 comments

Comments

@caoxuanyu
Copy link

var success = RedisHelper.ZScore("CG_001", 591);
System.FormatException:“Input string was not in a correct format.”

@2881099
Copy link
Owner

2881099 commented Mar 24, 2020

去 redis-cli 执行这个命令试试

@2881099
Copy link
Owner

2881099 commented Mar 24, 2020

zscore CG_001 591

返回的内容是什么?现在解析是用的 decimal.Parse(""),有可能是这里报错

@caoxuanyu
Copy link
Author

Redis中用ZSet存的数据为:
集合:CG_001 Value:591 Score:637206661468323200
我想用Value的591 返回Score的值转换成时间来做延时队列

@caoxuanyu
Copy link
Author

zscore CG_001 591

返回的内容是什么?现在解析是用的 decimal.Parse(""),有可能是这里报错

public static decimal? ZScore(string key, object member);

这个方法的Value值也就是 member 是Object啊。
RedisHelper.ZRem 传的是同样的值,方法没问题,可正常执行

@2881099
Copy link
Owner

2881099 commented Mar 24, 2020

现在手机,给个建议时间可以按2000年,或者1970计算秒数做 score,这样能保证数字小一点,晚一点我试试

@2881099
Copy link
Owner

2881099 commented Mar 24, 2020

127.0.0.1:6379> zscore CG_001 591
"6.372066614683232e+017"

> decimal.Parse("6.372066614683232e+017")
System.FormatException: 输入字符串的格式不正确。
+ System.Number.StringToNumber(string, System.Globalization.NumberStyles, ref System.Number.NumberBuffer, System.Globalization.NumberFormatInfo, bool)
+ System.Number.ParseDecimal(string, System.Globalization.NumberStyles, System.Globalization.NumberFormatInfo)
+ .MoveNext()

@2881099
Copy link
Owner

2881099 commented Mar 24, 2020

请升级到 v3.5.5

@caoxuanyu
Copy link
Author

好了。更新到新版本问题解决。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants