Skip to content
This repository was archived by the owner on Dec 27, 2023. It is now read-only.
This repository was archived by the owner on Dec 27, 2023. It is now read-only.

Increase performance by skipping has() #1

@BartVB

Description

@BartVB

First of all; thank you for creating this adapter! It's a great help with transitioning from one storage platform to another.

I would like to make one suggestion though. Currently this is the read() method:

    public function read($path)
    {
        if ($this->mainAdapter->has($path)) {
            return $this->mainAdapter->read($path);
        }

        $result = $this->fallback->read($path);

        if (false !== $result && $this->forceCopyOnMain) {
            $this->mainAdapter->write($path, $result['contents'], new Config());
        }

        return $result;
    }

Could the first part be changed to:

        $result = $this->mainAdapter->read($path); 
        if (false !== $result) {
            return $result;
        }

This results in a 50% reduction in API calls for all reads and in the end we don't really care if the main adapter has() the requested object, all we want to know if we can read() it. Same thing goes for most other methods.

Thanks again!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions