Skip to content

Commit

Permalink
When renaming an existing hash key, remove the old one after creating…
Browse files Browse the repository at this point in the history
… the new one.
  • Loading branch information
tapvt committed Dec 1, 2011
1 parent 6025082 commit 19cd002
Showing 1 changed file with 21 additions and 16 deletions.
37 changes: 21 additions & 16 deletions edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,22 @@



// Are we editing or creating a new key?
$edit = false;

if (isset($_GET['key'], $_GET['type'])) {
if (($_GET['type'] == 'string') ||
(($_GET['type'] == 'hash') && isset($_GET['hkey'])) ||
(($_GET['type'] == 'list') && isset($_GET['index'])) ||
(($_GET['type'] == 'set' ) && isset($_GET['value'])) ||
(($_GET['type'] == 'zset') && isset($_GET['value']))) {
$edit = true;
}
}




if (isset($_POST['type'], $_POST['key'], $_POST['value'])) {
// Don't allow keys that are to long (Redis supports keys that can be way to long to put in an url).
if (strlen($_POST['key']) > $config['maxkeylen']) {
Expand All @@ -23,6 +39,11 @@
}

$redis->hSet($_POST['key'], $_POST['hkey'], $_POST['value']);

if ($edit) {
$redis->hDel($_POST['key'], $_GET['hkey']);
}

}

// List
Expand Down Expand Up @@ -79,22 +100,6 @@



// Are we editing or creating a new key?
$edit = false;

if (isset($_GET['key'], $_GET['type'])) {
if (($_GET['type'] == 'string') ||
(($_GET['type'] == 'hash') && isset($_GET['hkey'])) ||
(($_GET['type'] == 'list') && isset($_GET['index'])) ||
(($_GET['type'] == 'set' ) && isset($_GET['value'])) ||
(($_GET['type'] == 'zset') && isset($_GET['value']))) {
$edit = true;
}
}




// Get the current value.
$value = '';

Expand Down

0 comments on commit 19cd002

Please sign in to comment.