Skip to content

NullAdapter save() method behavior #40753

Closed
@roukmoute

Description

@roukmoute

Symfony version(s) affected: 4 and 5

Description

I would like to discuss the save() method in NullAdapter.
I find it strange that the save() method returns false.
If we have a condition that verifies that the save() happened and the NullAdapter is used for testing, it should not return false.
It should work as if it had no cache, and then it will create it.
In my opinion, the NullAdapter should not default to a reaction that should be transparent.

I would like to know what you think about changing this method to return true.

How to reproduce

$adapter = new NullAdapter();
$item = new CacheItem();
$item->set('FooBar');
if (!$adapter->save($item)) {
    throw new Exception('Uoh oh');
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions