alicebob / miniredis

Pure Go Redis server for Go unittests
MIT License
3.1k stars 217 forks source link

Memory Usage #341

Closed davidroman0O closed 1 year ago

davidroman0O commented 1 year ago

It won't be 1:1 to Redis since it's adding overhead.

MEMORY USAGE foo

It's quite simple and using a dependency that got one file.

Story time: I was experimenting with miniredis + asynq + rueidis all on the same codebase just for fun, when i wanted to call GetTaskInfo of asynq which lead me to this lua code that was throwing an error because miniredis was missing MEMORY USAGE. Using miniredis just like i would use sqlite is just awesome.

Please consider allowing sponsoring, I like to donate a bit for the code I use for my side projects :)

This PR will help asynq even though the maintainer doesn't even know about this case

alicebob commented 1 year ago

Hi,

thanks for the PR and the kind words. I prefer to not have a dependency for something used this rare, but since the license is MIT we could add the file to the codebase (same as geohash and hyperloglog). Just that one file and the license+credits, I guess. And could you add a small test in ./integration? There's a DoLoosly() which compares the returned structure only and not the exact values.

davidroman0O commented 1 year ago

That would do, I guess

I've changed the requirements a little bit since after re-reading the documentation this morning, it require to work on all types so I used the master map to switch on the types. I hope i didn't forgot something.

The size package is within a folder which contains a readme, I don't know how to proceed for the credits though!

I've added two lines in the integration, i don't if it's what you wanted :P

go.exe test -timeout 30s -run ^TestServer$ github.com/alicebob/miniredis/v2/integration
ok      github.com/alicebob/miniredis/v2/integration    0.192s
alicebob commented 1 year ago

Thanks for the fixes. It looks good, but I'll have a proper look soon. Can you squash it all so it's easier to merge? Thanks!

davidroman0O commented 1 year ago

I think i need to sleep before doing other mistakes

alicebob commented 1 year ago

Merged, with some small fixes. I hope you got the credits for the commit. I'll make it a proper release in a few days.

(The tests in ./integration go against a real redis. If you run make in there it works: it will run INT=1 go test. If the tests can't find redis on your system you can run ./get_redis.sh to install it in a subdir there).