Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Cache] Make ArrayAdapter and NullAdapter taggable #61114

@dmitryuk

Description

@dmitryuk

Description

Hello. The issue that I use RedisTagAwareAdapter for production, but need to test it in memory with ArrayAdapter or NullAdapter, which doesn't implements TagAwareAdapterInterface.

So for tests in production code I should check if adapter implements TagAwareAdapterInterface and, for example, add tags to cache item:

// production code below
// adapter can be RedisTagAwareAdapter or ArrayAdapter or NullAdapter
        if ($this->adapter instanceof TagAwareAdapterInterface) {
            $item->tag([self::TAG]);
        }

Without checking I will get an error 'Cache item "%s" comes from a non tag-aware pool: you cannot tag it.'.
Finally code is not totally covered

I think will be great to create new class ArrayTagAwareAdapter and add interface TagAwareAdapterInterface to NullAdapter out-of-box to easier test Cache layer.

What do you think?

p.s. before doing a PR I started this short discussion

Example

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions