StackExchange / StackExchange/StackExchange.Redis

Storing decimal values in redis

Open
#2,579 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
6.2k
Forks
1.6k
Avg merge
1d 15h
Merged PRs (30d)
43

Description

When I have to store decimals I convert them to a string in order to be able to use stack exchange API.

In the parsing method, there is no case for decimals. Is there a specific reason for it or it is a bug.

internal static RedisValue TryParse(object? obj, out bool valid)
{
    valid = true;
    switch (obj)
    {
        case null: return Null;
        case string v: return v;
        case int v: return v;
        case uint v: return v;
        case double v: return v;
        case byte[] v: return v;
        case bool v: return v;
        case long v: return v;
        case ulong v: return v;
        case float v: return v;
        case ReadOnlyMemory<byte> v: return v;
        case Memory<byte> v: return v;
        case RedisValue v: return v;
        default:
            valid = false;
            return Null;
    }
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the internal TryParse(object? obj, out bool valid) method shown in the issue and review how supported numeric values are converted to RedisValue. Confirm the intended decimal behavior with the project’s existing tests or test structure; done means decimal values can be stored without requiring callers to convert them to strings.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, redis
Domain
database
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.