YouTip LogoYouTip

Hashes Hincrby

Redis Hincrby Command | SimplestTutorials.com window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'G-9B3Z6N5K2D'); .article-content { font-size: 16px; line-height: 1.7; margin-top: 20px; } pre { background-color: #f4f4f4; border: 1px solid #ddd; padding: 15px; overflow-x: auto; border-radius: 5px; font-family: "Courier New", monospace; font-size: 14px; } code { font-family: "Courier New", monospace; font-size: 14px; } .note { background-color: #f0f8ff; border-left: 4px solid #007cba; padding: 10px; margin: 15px 0; font-size: 14px; } .header { text-align: center; margin-bottom: 30px; } .header h1 { font-size: 2em; color: #333; } .header p { font-size: 1.1em; color: #666; } .nav-links { list-style-type: none; padding: 0; margin: 0; display: flex; justify-content: center; flex-wrap: wrap; gap: 15px; } .nav-links li a { text-decoration: none; color: #007cba; font-weight: bold; transition: color 0.3s ease; } .nav-links li a:hover { color: #005a87; } .footer { text-align: center; margin-top: 40px; padding: 20px; background-color: #f8f8f8; border-top: 1px solid #ddd; font-size: 14px; color: #666; }

Redis Hincrby Command | SimplestTutorials.com

Learn not just technology, but also dreams!

Redis Tutorial

Redis Commands

Advanced Redis Tutorials

Note: This tutorial is part of the comprehensive learning journey offered by SimplestTutorials.com β€” where we don’t just teach technology, we inspire dreams.

Redis Hincrby Command

Up Redis Hashes (Hash)

The HINCRBY command in Redis is used to increment the value of a field in a hash table by a specified amount.

The increment can also be negative, which effectively performs a subtraction operation on the specified field.

If the hash table key does not exist, a new hash table will be created and the HINCRBY command will be executed.

If the specified field does not exist, its value is initialized to 0 before executing the command.

Executing HINCRBY on a field that stores a string value will result in an error.

The value of this operation is restricted to a 64-bit signed integer.

Syntax

The basic syntax for the Redis HINCRBY command is as follows:

redis 127.0.0.1:6379> HINCRBY KEY_NAME FIELD_NAME INCR_BY_NUMBER

Available Version

>= 2.0.0

Returns

The updated value of the field in the hash table after executing the HINCRBY command.

Examples

redis> HSET myhash field 5
(integer) 1
redis> HINCRBY myhash field 1
(integer) 6
redis> HINCRBY myhash field -1
(integer) 5
redis> HINCRBY myhash field -10
(integer) -5
redis>
Up Redis Hashes (Hash)

← Hashes HincrbyfloatHashes Hgetall β†’

YouTip © 2024-2026 | Home | Learn Technology, Build Dreams!

All content is for educational and learning purposes only.