Permalink
Browse files

Fixed GETRANGE

  • Loading branch information...
1 parent d8ee0e4 commit 392dfd552d3e4b55cc7836778f919b30fe132101 @tj committed Apr 15, 2011
Showing with 7 additions and 10 deletions.
  1. +7 −10 lib/commands/string.js
View
@@ -221,12 +221,15 @@ exports.strlen = function(client, key){
*/
exports.getrange = function(client, key, from, to){
- var key = string(key)
- , val = this.data[key]
- , len = val.length
+ var obj = this.lookup(string(key))
, from = +string(from)
, to = +string(to);
+ if (!obj) return client.nil();
+ if ('string' != obj.type) return client.typeError();
+
+ var len = obj.val.length;
+
if (isNaN(from)) return client.typeError();
if (isNaN(to)) return client.typeError();
@@ -242,13 +245,7 @@ exports.getrange = function(client, key, from, to){
if (to < 0) to = 0;
if (from < 0) from = 0;
- if (null == val) {
- client.nil();
- } else if ('string' == this.keyType(key)) {
- client.send(val.slice(from, to + 1));
- } else {
- client.typeError();
- }
+ client.send(obj.val.slice(from, to + 1));
};
/**

0 comments on commit 392dfd5

Please sign in to comment.