Skip to content

Commit

Permalink
List support
Browse files Browse the repository at this point in the history
  • Loading branch information
makmonty committed Mar 7, 2012
1 parent 6d00d54 commit 39cc137
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
34 changes: 34 additions & 0 deletions controllers/ListController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

class ListController extends RedisController implements iRedisType
{


public function addField(){
$this->redis->rpush($this->params['key'], $this->params['value']);
$this->getAllFields($this->params['key']);
}

public function editField(){
$bool = $this->redis->lset($this->params['key'], $this->params['field'], $this->params['value']);
echo json_encode($bool);

}
public function getValues(){
$this->getAllFields($this->params['key']);
}









private function getAllFields($key){
$size = $this->redis->llen($key);
$fields = $this->redis->lrange($key, 0, $size-1);

This comment has been minimized.

Copy link
@johanlaidlaw

johanlaidlaw Mar 9, 2012

You can just use -1 instead of $size-1
$fields = $this->redis->lrange($key, 0, -1);

$this->returnAllFields($fields, 'list');
}
}
1 change: 1 addition & 0 deletions css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ body{ font-family: Georgia; margin:0; }
.redis_value_container{ padding-left: 30px; }
.r_field{ color:#6E0D0D; }
.r_key { padding:5px 5px 5px 10px; border-bottom:1px solid #eee; border-right:1px solid #eee; }
.r_key .key_type { font-size:0.7em; color:#bbb; }
.r_value{ color:#025403; }
.r_member { padding:3px; border-bottom:1px solid #eee; }

Expand Down
2 changes: 1 addition & 1 deletion js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ function getKeys(){
element = '';

$.each(data.keys, function(i, item){
element += '<div class="r_key" type="'+item[1]+'"><span class="key_name">'+item[0]+'</span> <img class="delete_key" src="img/trash.png" style="display: none; vertical-align: bottom" /></div>';
element += '<div class="r_key" type="'+item[1]+'"><span class="key_name">'+item[0]+'</span> <span class="key_type">'+item[1]+'</span> <img class="delete_key" src="img/trash.png" style="display: none; vertical-align: bottom" /></div>';
});
$("#redis_container").html(element);
}
Expand Down

0 comments on commit 39cc137

Please sign in to comment.