To build RedisDecimal, ensure you have cmake and make, and afterwards run the following command.
cmake .
makeIf the build is successful, you'll have a shared library called libdecimal.so in the lib directory.
To load the library, pass its path to the --loadmodule directive when starting redis-server:
$ redis-server --loadmodule ./lib/libdecimal.so# redis-cli
127.0.0.1:6379>And run the following command:
127.0.0.1:6379> DECIMAL ADD 10 20
"30.000000"
127.0.0.1:6379> DECIMAL SUB 10 20
"-10.000000"
127.0.0.1:6379> DECIMAL MUL 10 20
"200.000000"
127.0.0.1:6379> DECIMAL DIV 10 20
"0.500000"And specify the precision:
127.0.0.1:6379> DECIMAL ADD 10 20 2
"30.00"
127.0.0.1:6379> DECIMAL SUB 10 20 2
"-10.00"
127.0.0.1:6379> DECIMAL MUL 10 20 2
"200.00"
127.0.0.1:6379> DECIMAL DIV 10 20 2
"0.50"And round policy for division:
127.0.0.1:6379> DECIMAL DIV 10 3 2
"3.33"
127.0.0.1:6379> DECIMAL DIV 20 3 2
"6.66"To build RedisDecimal, and run the unit testing.
cmake .
make
./.tests/tests