StackExchange / StackExchange.Redis

General purpose redis client
https://stackexchange.github.io/StackExchange.Redis/
Other
5.87k stars 1.51k forks source link

why HashScan not work? #1873

Open kasini3000 opened 2 years ago

kasini3000 commented 2 years ago

HashScan not work . SetScan,SortedSetScan,not work too.

What libraries does hashscan depend on? Maybe i didn't import

all lib ,i imported. version ,from nuget

.net50\StackExchange.Redis=2.2.50.36290 .net50\Pipelines.Sockets.Unofficial.dll=2.2.0.45337 .net50\System.IO.Pipelines.dll=5.0.20.51904

powershell source

$hash = [StackExchange.Redis.RedisKey]"hash2"
$patt = [StackExchange.Redis.RedisValue]"a*"
$page = [int]50
$flag = [StackExchange.Redis.CommandFlags]::None
$Global:db1.HashScan($hash,$patt,$page,$flag)
MethodException: Cannot find an overload for "HashScan" and the argument count: "4".

$Global:db1.HashScan

OverloadDefinitions
-------------------
System.Collections.Generic.IEnumerable[StackExchange.Redis.HashEntry] IDatabase.HashScan(StackExchange.Redis.RedisKey key, StackExchange.R
edis.RedisValue pattern, int pageSize, StackExchange.Redis.CommandFlags flags)
System.Collections.Generic.IEnumerable[StackExchange.Redis.HashEntry] IDatabase.HashScan(StackExchange.Redis.RedisKey key, StackExchange.R
edis.RedisValue pattern, int pageSize, long cursor, int pageOffset, StackExchange.Redis.CommandFlags flags)

[string]$Global:db1.HashGetall($hash)
aaa_1_2: b c_2_9: aaaa
mgravell commented 2 years ago

That's a great question, but it feels like a powershell question - and I for one: am not a powershell expert. The one it wants is right there (the first one). I assume db1 here came from GetDatabase() ?

@NickCraver - you know more about powershell than me; any idea why it might not be seeing this method?

NickCraver commented 2 years ago

Indeed we need to see how the db1 global is defined - @kasini3000 can you show where that's coming from?

kasini3000 commented 2 years ago

yes , return from GetDatabase() see:

$Global:db1 = $Global:redis_conn1.GetDatabase(1)

q:why use $Global:db1? a: it can use both script and powershell console, let me call method easy. can use $db1.method() also,eg:

 $db1.HashGetAll('hash2')

Name    Value Key
----    ----- ---
aaa_1_2 b     aaa_1_2
c_2_9   aaaa  c_2_9

where find StackExchange.Redis api manual? I want to look at the inheritance of classes and the reference relationship of library files.