-
Notifications
You must be signed in to change notification settings - Fork 64
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
Implement keys API in test executor #194 #480
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few remarks, other than that it looks great!
@@ -650,6 +660,193 @@ private[redis] final class TestExecutor private ( | |||
) | |||
} | |||
|
|||
case api.Keys.Exists | api.Keys.Touch => | |||
val allkeys = input.map(_.asString) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be part of fold, e.g.:
STM.foldLefft(input)(0L) { case (acc, key) =>
// key.asString
}
This pattern is repeated a few times so please adjust all occurrences.
val options = input.drop(1).map(_.asString) | ||
|
||
val countIndex = options.indexOf("COUNT") | ||
val count = Option.when(countIndex >= 0)(options(countIndex + 1).toInt) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that Option.when
won't work in 2.12.
|
||
case api.Keys.Expire => | ||
val key = input(0).asString | ||
val unixtime = now.plusSeconds(input(1).asLong) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be suspended, but since we don't have a proper solution for clock in stm, it can stay.
_ <- if (newHash.isEmpty) delete(key) | ||
else putHash(key, newHash) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should be able to use ZIO.cond
for all similar occurrences.
case class KeyInfo(`type`: KeyType, expireAt: Option[Instant]) { | ||
lazy val redisType: RedisType = KeyType.toRedisType(`type`) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make it final.
fix compilation errors for scala 2.12
This PR is continuation of PR #371
Some changes in the concept how we save expiration time, before there was an idea to have two separated stores for keys and expiration time, I do not very like that idea because it doesn't have good scale options. I decided to unite them in one key store where we save all information about our key: type, expiration time, etc.