Skip to content

Empty String Stored when cache_nils: false and raw: true #1022

@nickamorim

Description

@nickamorim

Description

When storing a nil value with the raw: true request option, Dalli stores an empty string even though cache_nils is false [ref]. This especially doesn't play nice with a custom serializer. @petergoldstein I'm curious to get your thoughts on whether we should instead raise an ArgumentError in this situation instead of storing an empty string (although it would be a breaking change).

irb(main):001> require "dalli"
irb(main):002> c = Dalli::Client.new("127.0.0.1:11211", cache_nils: false)
irb(main):003> c.set("foo", nil, 0, raw: true)
irb(main):004> c.get("foo")
=> ""

Expected Behaviour

irb(main):001> require "dalli"
irb(main):002> c = Dalli::Client.new("127.0.0.1:11211", cache_nils: false)
irb(main):003> c.set("foo", nil, 0, raw: true) <= ArgumentError

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions