This is the implementation that was requested in the original issue. I updated KEYS command to be redis-valid and implemented prefix search. There is also a rather interesting test, I could you use some feedback here.
I noticed that it might not be possible to reduce the complexity of the KEYS command. Because even if you use Scan, you will have to store the counter of all found keys before you do WriteBulk of the actual keys.
Yeah you're right! YOu'd have to accumulate the metched keys sadly.
I think what you've done here in this PR is great though and it will perform much better with a database with a larger keyspace. Iteresting through hundreds or thousands of keys will be slow, so reducing that space with ascan is goo.d