Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
K
key_value-server
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
amir.yosef
key_value-server
Commits
d8ae6da7
Commit
d8ae6da7
authored
Aug 13, 2024
by
amir.yosef
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
handling unknown commands
parent
c9425153
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
5 additions
and
4 deletions
+5
-4
SetCommand.java
src/command/SetCommand.java
+2
-2
Command.java
src/model/Command.java
+2
-1
CommandUtil.java
src/util/CommandUtil.java
+1
-1
No files found.
src/command/SetCommand.java
View file @
d8ae6da7
...
...
@@ -11,7 +11,7 @@ import java.util.Map;
public
class
SetCommand
implements
CommandHandler
{
private
final
Storage
storage
=
Storage
.
getInstance
();
private
final
List
<
String
>
args
;
private
final
List
<
String
>
args
;
public
SetCommand
(
List
<
String
>
args
)
{
this
.
args
=
args
;
...
...
@@ -32,7 +32,7 @@ public class SetCommand implements CommandHandler {
if
(
expiration
!=
null
)
{
try
{
Long
expirationTime
=
Long
.
parseLong
(
expiration
);
storage
.
save
(
args
.
getFirst
().
toLowerCase
(),
value
,
expirationTime
);
storage
.
save
(
args
.
getFirst
().
toLowerCase
(),
value
,
expirationTime
);
}
catch
(
NumberFormatException
e
)
{
System
.
out
.
println
(
"NumberFormatException: "
+
e
.
getMessage
());
}
...
...
src/model/Command.java
View file @
d8ae6da7
...
...
@@ -21,7 +21,8 @@ public enum Command {
WAIT
(
"WAIT"
),
XADD
(
"XADD"
),
XRANGE
(
"XRANGE"
),
XREAD
(
"XREAD"
),
MULTI
(
"MULTI"
),
EXEC
(
"EXEC"
),
DISCARD
(
"DISCARD"
);
XREAD
(
"XREAD"
),
MULTI
(
"MULTI"
),
EXEC
(
"EXEC"
),
DISCARD
(
"DISCARD"
),
UNKNOWN
(
"UNKNOWN"
);
private
final
String
value
;
...
...
src/util/CommandUtil.java
View file @
d8ae6da7
...
...
@@ -42,6 +42,6 @@ public class CommandUtil {
return
Command
.
EXEC
;
}
else
if
(
command
.
toLowerCase
().
contains
(
Command
.
DISCARD
.
getValue
())
||
command
.
equalsIgnoreCase
(
Command
.
DISCARD
.
getValue
()))
{
return
Command
.
DISCARD
;
}
else
return
null
;
}
else
return
Command
.
UNKNOWN
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment