8000 [Cache] Define multiple Memcached servers in framework.yaml · Issue #27855 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Cache] Define multiple Memcached servers in framework.yaml #27855

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

Closed
websirnik opened this issue Jul 5, 2018 · 6 comments
Closed

[Cache] Define multiple Memcached servers in framework.yaml #27855

websirnik opened this issue Jul 5, 2018 · 6 comments

Comments

@websirnik
Copy link

At the moment it's not possible to define multiple Memcached servers in framework.yaml. Would be useful to extend this ability to be able to do either:

framework:
    cache:
        default_memcached_provider: memcached://server1:1111,server2:2222

or

framework:
    cache:
        default_memcached_provider:
            - memcached://server1:1111
            - memcached://server2:2222
@websirnik websirnik changed the title Define multiple Memcached servers in framework.yaml [Cache] Define multiple Memcached servers in framework.yaml Jul 5, 2018
@nicolas-grekas
Copy link
Member

I know this is not exactly your suggestion, but did you try creating the provider service directly using MemcachedAdapter::createConnection? I think that could be a good start to wonder how this could work (and validate if this is needed or not).

@websirnik
Copy link
Author

Yes, I'm creating a connection via service at the moment. Two shortcomings of custom service are:

  1. I can't create Cache Pool(i might just haven't figured out how)
  2. Service requires extra logic to configure different instances with options for different environments where config.yml would simplify that.

@nicolas-grekas
Copy link
Member

I can't create Cache Pool(i might just haven't figured out how)

does that work?

framework:
    cache:
        default_memcached_provider: your_memcached_connection_service

Service requires extra logic to configure different instances with options for different environments where config.yml would simplify that.

can't you use env vars in your_memcached_connection_service do to that?

if those two answers are OK to you, do we still need a config option? (the less options the better usually ;) )

@nicolas-grekas
Copy link
Member

Related to #28300 and #28175 I suppose, which also ask for multi-server setups for Redis.
A similar DSN format for both backends would be great BTW.

@nicolas-grekas
Copy link
Member

See proposal in #28300 (comment)

@nicolas-grekas
Copy link
Member

Implemented in #28598

@fabpot fabpot closed this as completed Sep 26, 2018
fabpot added a commit that referenced this issue Sep 26, 2018
… in one DSN (nicolas-grekas)

This PR was merged into the 4.2-dev branch.

Discussion
----------

[Cache] support configuring multiple Memcached servers in one DSN

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #27855
| License       | MIT
| Doc PR        | symfony/symfony-docs#10402

Useful to reconfigure dynamically an array of memcached servers (eg removing a dead one or adding a new one).
DSN format is e.g. `memcached://localhost?host[foo.bar]=3`.
To ease generating the DSN programmatically, it works also with `memcached:?host[localhost]&host[localhost:12345]&host[/some/memcached.sock:]=3`.

The key of the "host" parameter is a "host:port" pair, the value is the weight of the "host:port" pair.
Sockets need to be specified with the trailing `:` (as shown in the last example).

Commits
-------

8e0605a [Cache] support configuring multiple Memcached servers in one DSN
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants
0