Comments (6)
from miniredis.
Hi @zikaeroh,
I've implemented it in #87. I choose to do this in NewMiniRedis():
source := rand.NewSource(rand.Int63())
m := Miniredis{
....
rand: rand.New(source),
}
This way seeding the global source still has some effect in Miniredis, while it give the option to override the seed. It's not 100% the same as before, but it's the simplest thing to do.
from miniredis.
I'll be happy to look at it more closely later. My first impression (skimming on my phone) that it'd definitely lead to different results between miniredis versions (since you're using a seed from Rand), and might also require some locking, but I haven't tested to see. I had actually been planning on submitting my own PR for consideration (but hadn't had time since asking).
from miniredis.
I opened a slightly different PR (#89) for your consideration; this one instead calls the global rand as it would have before, but will switch to an internal version when requested. I think this is better than always using an internal copy with rand.Int63()
as a seed because:
- Using
rand.Int63()
changes the seed used (as it wouldn't output1
, Go's default seed), so those who had used the old advice ofrand.Seed
would have broke those users. - The library would still rely on global state; every miniredis instance created would call
rand.Int63()
and would all behave differently (in case a test creates more than one server, only has one of them use randomness, etc).
from miniredis.
from miniredis.
Sure, random is random, except that existing users may have already taken the advice of using the global seed in non parallel tests, and would otherwise be broken. (The fact that we can seed at all is really because it's only psuedorandom anyway, which is intended.)
from miniredis.
Related Issues (20)
- Can miniredis be used in production server? HOT 3
- GETEX seems to be not supported. HOT 1
- Intermittent panic when go test with -coverpkg HOT 7
- my mistake
- How to use Hgetall or Hmset by miniredis? HOT 1
- Problem about overflow inspection of INCRBY/DECRBY HOT 1
- Stream XREAD last ID '$' has incorrect behavior when blocking forever HOT 4
- EXPIRETIME is not implemented
- MEMORY USAGE command
- Race in stream when using blocking calls
- support for redis v8 HOT 2
- need export non-lock version function like RedisDB.stringGet
- ZMSCORE unsupported HOT 3
- expire time invalid HOT 5
- RESP3 Issues HOT 9
- Wrong behavior with SET NX GET HOT 4
- how can i know the miniredis was close HOT 2
- MEMORY USAGE command HOT 2
- Special lastId=$ not working with XREAD HOT 2
- Blocking calls from lua always deadlock HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from miniredis.