Code Monkey home page Code Monkey logo

Comments (11)

weierophinney avatar weierophinney commented on June 14, 2024

It's protected likely as it was only intended for internal purposes.

That said, you have 3 options:

  • Extend the class and make the method public:
public function getRedisResource()
{
    return parent::getRedisResource();
}

If you go this route, you'll also need to provide a custom factory to ensure your own adapter is used.

  • Use reflection to make the method accessible, and then call it:
$r = new ReflectionMethod($adapter, 'getRedisResource');
$r->setAccessible(true);
$resource = $r->invoke($adapter);
  • Send a pull request that changes the visibility of the method.

from zend-cache.

pensiero avatar pensiero commented on June 14, 2024

Thanks a lot @weierophinney, I'll send a PR and meanwhile I use the second method 👍

from zend-cache.

pensiero avatar pensiero commented on June 14, 2024

@weierophinney do you think it would be nice to change to public the same method in each adapter? (Redis/Memcached/Apc...)

from zend-cache.

weierophinney avatar weierophinney commented on June 14, 2024

Yes; it's useful to be able to share the adapters, and we cannot assume
everything is configured under our own service manager.

On Tue, Jun 16, 2015 at 9:52 AM, Oscar Fanelli [email protected]
wrote:

@weierophinney https://github.com/weierophinney do you think it would
be nice to change to public the same method in each adapter?
(Redis/Memcached/Apc...) ?


Reply to this email directly or view it on GitHub
#12 (comment)
.

Matthew Weier O'Phinney
[email protected]
https://mwop.net/

from zend-cache.

marc-mabe avatar marc-mabe commented on June 14, 2024

@pensiero @weierophinney The resources of all resource based storages are already public accessible from the resource manager. $storage->getOptions()->getResourceManager()->getResource()

The resource manager is where you configure and share resources.

from zend-cache.

pensiero avatar pensiero commented on June 14, 2024

@marc-mabe yes, but you can't access to the resource manager from the adapter

from zend-cache.

marc-mabe avatar marc-mabe commented on June 14, 2024

You can as seen in my example above. The $storage variable holds the adapter instance.

from zend-cache.

pensiero avatar pensiero commented on June 14, 2024

mmmmmm i'm not so skilled to say that this could be a better way or not... @weierophinney and others, what do you think about it?

from zend-cache.

Maks3w avatar Maks3w commented on June 14, 2024

@marc-mabe give a hint about to have a common API for getResource() as discussed in #13

Could we just write a proxy method in the adapter?

// Adapter.php
public function getResource() {
  return $this->getOptions()->getResourceManager()->getResource();
}

from zend-cache.

marc-mabe avatar marc-mabe commented on June 14, 2024

@Maks3w Indeed it would be pretty simple to write a proxy method this is in the adapter and that's what @pensiero does in #13. I only figured out he was though it is currently not possible to get the resource but it is.

About a common API (like getResource) I dislike this approve as the return value will be very specific. What @weierophinney already pointed out. The one adapter returns an object another one a resource type and the next one a very different object. In PHP this is possible but it doesn't mean it makes any sense.

from zend-cache.

marc-mabe avatar marc-mabe commented on June 14, 2024

Closed as discussed in #13

from zend-cache.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.