Command: NUM.SET


Overview

The NUM.SET command stores a numeric value (integer or floating-point) in the key-value database. This command is designed to handle numerical data efficiently.


Command Name

NUM.SET


Description

Stores a numeric value under a specific key in the database. The value can be any valid number format such as int , float32 , or float64 . If the key already exists, its value is overwritten.

Syntax

  NUM.SET <key> <value>
  
  • <key> : A valid string identifier where the number will be stored.

  • <value> : A valid numeric value (integer or float).

Permissions

  • No special permissions are required to execute this command.

  • Users must have access to the shard where the key is mapped.


Input Examples

  localhost:9219> NUM.SET myInt 42
Ok

localhost:9219> NUM.SET pi 3.14159
Ok

localhost:9219> NUM.SET balance -99.75
Ok
  

Output Examples

  localhost:9219> NUM.SET myInt 42
Ok

localhost:9219> GET myInt
Ok 42

localhost:9219> NUM.SET balance -99.75
Ok

localhost:9219> GET balance
Ok -99.75
  

Behavior on Error

Error Scenario Error Message
No key provided InvalidKeyError: Key must be provided
Incorrect number of arguments InvalidArgsError: invalid number of arguments
Invalid key format InvalidKeyError: <reason>
Value is not a number InvalidValueError: provided value is not a valid number

Use Cases

  • Store User Balances

      NUM.SET user:1001:balance 123.45
      
  • Cache Calculated Values

      NUM.SET temperature:nyc 25.6
      
  • Replace Previous Values

      NUM.SET retry_count 5
    NUM.SET retry_count 6
      
  • Store Negative or Floating Values

      NUM.SET altitude -431.2