diff --git a/src/redisAuth.m b/src/redisAuth.m new file mode 100644 index 0000000..5768f7e --- /dev/null +++ b/src/redisAuth.m @@ -0,0 +1,20 @@ +function [R, S] = redisSet(R, pwd) + +S = 'OK'; + +if ~isstr(pwd) + S = 'ERROR - AUTH PWD MUST BE A STRING'; + return +end + +if ~strcmp(R.status, 'open') + S = 'ERROR - NO CONNECTION'; + return +end + +[Response, R, S] = redisCommand(R, redisCommandString(sprintf('AUTH %s', pwd))); + +if strcmp(Response, '+OK') + S = Response; + return +end \ No newline at end of file diff --git a/test/test.m b/test/test.m index 2d2f092..88a0c43 100644 --- a/test/test.m +++ b/test/test.m @@ -7,6 +7,9 @@ function test() [R, M] = redisConnection(); assert_string(M, 'OK'); +% [R, M] = redisAuth(R, ''); +% assert_string(M, 'OK'); + [Value, R, M] = redisPing(R); assert_string(Value, 'PONG');