Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add IMultiReadStorage #2

Closed
fprochazka opened this issue Jun 5, 2014 · 5 comments
Closed

Add IMultiReadStorage #2

fprochazka opened this issue Jun 5, 2014 · 5 comments

Comments

@fprochazka
Copy link
Contributor

@fprochazka fprochazka commented Jun 5, 2014

I propose adding a new interface IMultiReadStorage that will extend Nette\Caching\IStorage and it's implementation would mean that the cache can utilize the storage more effectively. Because reading 100 keys from memory cache at once is more effective than 100 requests.

Yes, this is a real world use-case, tested in our application and a friend on Posobota also told me he's using this approach.

We did implement our own IMultiReadStorage to Kdyby/Redis, but I wanna have a "standard" interface for my storage.

Also to the cache class should be added new method

class Cache
{
    public function multiLoad(array $keys)
    {
        if ($this->storage instanceof IMultiReadStorage) {
            return $this->storage->multiRead($keys);
        }

        $result = array();
        foreach ($keys as $key) {
            $result[$key] = $this->load($key);
        }
        return $result;
    }

To discuss:

  • should this be in Nette? (Should I send a pullrequest?)
  • better name for IMultiReadStorage ?
  • implementation details
@MartinMystikJonas

This comment has been minimized.

Copy link

@MartinMystikJonas MartinMystikJonas commented Jun 5, 2014

What about Batch or Bulk instead of Multi?

@Vrtak-CZ

This comment has been minimized.

Copy link

@Vrtak-CZ Vrtak-CZ commented Jun 5, 2014

👍 for Bulk

@fprochazka

This comment has been minimized.

Copy link
Contributor Author

@fprochazka fprochazka commented Jun 5, 2014

👍

@mishak87

This comment has been minimized.

Copy link

@mishak87 mishak87 commented Jun 5, 2014

IBulkLoadStorage::bulkLoad to keep the convention (not Read)

  • Add IBulkSaveStorage::bulkSave?
@fprochazka

This comment has been minimized.

Copy link
Contributor Author

@fprochazka fprochazka commented Jun 5, 2014

I don't think bulk save is neccesary.

matej21 added a commit to matej21/nette-caching that referenced this issue Apr 29, 2016
matej21 added a commit to matej21/nette-caching that referenced this issue Apr 29, 2016
matej21 added a commit to matej21/nette-caching that referenced this issue Apr 29, 2016
@dg dg closed this in aa11160 Jun 12, 2016
dg added a commit that referenced this issue Jun 12, 2016
dg added a commit that referenced this issue Jun 12, 2016
dg added a commit that referenced this issue Jun 14, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.