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

Change cache URL and port #5

Open
luisbatista opened this issue Nov 17, 2016 · 4 comments
Open

Change cache URL and port #5

luisbatista opened this issue Nov 17, 2016 · 4 comments
Labels
Milestone

Comments

@luisbatista
Copy link

Hello,

Is possible change the memcached url address?
Something like this: $Api->setCacheUrlAddress("http://new.endpoint.com")->setCacheUrlPort("11211") ?

(I need to use a 'memcached' outside of my server).

Can tell me how?

Best regards,
LB

@m1so
Copy link

m1so commented Nov 18, 2016

Hi,

you could implement your own CacheInterface, similar to the default one that uses Memcached and change the url/port there.

We could look into adding the url/port setters in the next release, what do you think @danijoo

@m1so m1so added the feature label Nov 18, 2016
@m1so m1so changed the title Change Memcached server url Change cache URL and port Nov 18, 2016
@dnlbauer
Copy link
Collaborator

Something like that should do it:

class Cache implements CacheInterface {
    public function __construct($url='localhost', $port=11211, $timeout=100)
    {
        $this->memcached = new Memcached;
        $this->memcached->addServer($url, $port, $timeout);
    }
}

Allows customization and we still can use it with default values w/o additional work.

An alternative approach that would allow multiple servers could be:

class Cache implements CacheInterface {
    public function __construct($addServer=true)
    {
        $this->memcached = new Memcached;
        if($addServer)
            $this->addServer()
    }

    public function addServer($url='localhost', $port=11211, $timeout=100)
    {
        $this->memcached->addServer($url, $port, $timeout);
    }
}

Allows to run with the default server or explicitly adding multiple custom servers with $cache->addServer(...)

Also, if someone has a redis implementation of Cacheinterface ready, i'd be happy to see it :)

@luisbatista
Copy link
Author

Hello danijoo,

Many thanks, I will try your suggestions

Best regards,
LB

@dnlbauer
Copy link
Collaborator

Feel free to make a push request if you have something nice :) Im sure
other ppl might need this too!

luisbatista [email protected] schrieb am Fr., 18. Nov. 2016 um
11:37 Uhr:

Hello danijoo,

Many thanks, I will try your suggestions

Best regards,
LB


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#5 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AEeQ8ozBKwwi_nWWw_t81Ztigsj9kjfYks5q_X_HgaJpZM4K1r8E
.

@m1so m1so added this to the 0.8 milestone Nov 22, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants