| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
| |
https://github.com/psf/black/blob/main/CHANGES.md
Run latest version of black to fix formatting issues
|
| |
|
|
|
|
|
|
|
|
| |
This test was written with the assumption
that sys.maxsize is equal to 2**63 - 1 everywhere.
sys.maxsize is equal to 2**31 - 1 on a 32-bit
platforms and 2**63 - 1 on a 64-bit platforms.
See also https://docs.python.org/3/library/sys.html#sys.maxsize
|
| | |
|
| |
|
|
|
|
|
| |
Add integration tests to reproduce the issue and add an argument to
_fetch_cmd to skip the key prefix logic as needed.
Closes #430
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| |
|
|
| |
See https://github.com/pinterest/pymemcache/issues/396 for more details
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
A stat with a blank value makes the .stats() call fail with index error.
```
memcache_connection.stats()
File "/lib/python3.6/site-packages/pymemcache/client/base.py", line 741, in stats
result = self._fetch_cmd(b'stats', args, False)
File "/lib/python3.6/site-packages/pymemcache/client/base.py", line 921, in _fetch_cmd
result[key_value[1]] = key_value[2]
IndexError: list index out of range
```
The line in question we saw that caused this:
```
b'STAT ep_initfile '
```
This fixes things to no longer blow up. I chose to use a blank binary string instead of None because I suspect other code might make assumptions about the data being binary strings due to this bug.
Co-authored-by: reecepeg <reecepeg@amazon.com>
|
| |
|
|
|
| |
This also drops support for passing None as a server spec, which is
something many tests were doing out of lazy convenience. I can't think
of a reason why we'd want to support that for real world usage.
|
| | |
|
| |
|
|
|
|
|
| |
The regular client supports noreply so pass args, kwargs like for other
functions in hash client
Fixes issue #360
|
| |
|
|
| |
https://black.readthedocs.io/en/stable/index.html
|
| |
|
|
|
|
|
|
|
|
|
|
| |
When using HashClient with ignore_exc, get would always return
None if no server is available and the default is passed as a
positional argument. The other clients return the default
value in this case. An earlier fix only had the desired effect when
passing default as a keyword argument.
For example, Django passes the default as a positional argument.
Return the default value so HashClient behaves like the other
clients.
|
| | |
|
| |
|
|
|
|
|
| |
ignore_exc should treat an error as a cache miss and default specifies
what should be returned on a miss.
Fixes issue #350
|
| | |
|
| | |
|
| |
|
|
|
| |
* future was needed for some python 2 specific tests
* use mock from unittest.mock instead of the 3rd party mock library
|
| |
|
|
|
|
|
| |
Now that we don't require Python 2 support no need for six.
Code upgraded with pyupgrade and manual fixes to remove remaining six
usage.
|
| |\
| |
| | |
Implement RetryingClient
|
| | | |
|
| | | |
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
During network maintenance operations or during server reboot users could
face MemcacheUnexpectedCloseError.
This kind of exception will be raised down the stack. It's a design
choice [1]. Users should manage this kind of exception.
However, at some points the opened sockets remains more or less opened
after this kind of fail on the client side [2]. It will require n+1
calls to see them recreated when the connection will be possible. That's
could be problem with services that implement several cache logics in parallel
and where their clients are based on pymemcache.
These changes simply ensure to close the socket properly. The socket
will be recreated by the client if needed.
[1] https://github.com/pinterest/pymemcache/issues/307
[2] https://bugzilla.redhat.com/show_bug.cgi?id=1977711
|
| | | |
|
| | | |
|
| |/
|
|
|
|
|
| |
9551dfd0 introduced a call to socket.getaddrinfo() to support IPv6, but
we never added an implementation of that function to MockSocketModule.
This resulted in some tests making "live" socket.getaddrinfo() calls
because of the default MockSocketModule.__getattr__ implementation
(which we need to forward other module attribute lookups).
|
| |
|
|
|
|
| |
The Memcached server can be configured to drop idle connections (via the
idle_timeout option). When this occurs, pymemcache may still try to
use the connection, resulting in MemcacheUnexpectedCloseError. Hence
the need for client-side idle timeout logic.
|
| | |
|
| |
|
|
|
|
|
| |
Overlooked when UNIX socket support was added to `HashClient` in
acd962b586a4fe018a00acb7e1621be373c13c3b.
Fixes #314.
|
| |
|
| |
According to the Memcached Protocol, the no argument form of the stats command should have no trailing spaces. Currently, b'stats \r\n' instead of b'stats\r\n' is being sent to the socket which leads to a malformed response.
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
_check_cas() does a good job of normalizing a CAS value and raising
MemcacheIllegalInputError when fed an invalid value. We were only using
this function in the `cas is not None` path within _store_cmd().
By moving this check into cas() itself, it allows us to also raise
MemcacheIllegalInputError when `cas is None`, which can happen when this
pattern is used for a new key:
val, cas = c.gets('key')
c.cas('key', 'value', cas)
|
| | |
|
| |
|
|
| |
Fixes #257.
|
| | |
|
| | |
|
| |
|
|
|
|
|
|
| |
Storing False when the client doesn't exist can be confused with False
being stored as the actual value. This behavior only occurred when using
ignore_exc=True.
Fixes #291.
|
| |
|
|
| |
Also added disconnect_all() as an alias for close().
|
| | |
|
| | |
|
| |
|
|
|
| |
The user can subclass Client (e.g to add telemetry or logging), and have
their custom client class used by PooledClient and HashClient to create
new clients.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
- Added `socket_module`, and `tls_context` parameters `__init__()`
- Added `socket_module`, `sock`, and `tls_context` attributes
- Added `replace()`
- Added `cas()` (which raises `MemcacheClientError` as `cas_enabled` is false for this `MockMemcacheClient`)
- Added `touch()`
- Added `cache_memlimit()`
- Added `version()`
- Added `flush_all()` (internally calling `clear()`)
- Added `quit()`
- Added `close()`
- Refactored `set()` to have default `flags` set to None
- Refactored `set_many()` to follow `Client`'s implementation (always return `[]` when `noreply` is True, else return the keys that were not inserted)
- Refactored `decr()` to have a similar implementation to `incr()` (also taking in account `noreply`'s value)
- Refactored `add()` to take in account `noreply`'s value
- Refactored `get_many()` to support `expire` and `flags`
- Refactored `stats()` to accepts arguments
- Refactored `append()`, `prepend()`, `set_many()`, and `add()` to forward `expire`, `noreply`, and `flags` to their internal call to `set()`
- Set all default value of `noreply` to True when it was None (since in Client, it uses `default_noreply` (set to True), when `noreply` is None)
- Set all default value of `expire` to 0
|
| | |
|
| |
|
|
|
| |
Looks like clients/hash behaves incorrectly when dead server comes back alive - it's never removed from dead_clients and thus retried indefinitely.
Failing test and fix are visible in 35ee9de, rest of PR simply adds some test coverage and refactors existing code a little.
|
| |
|
|
|
|
|
|
| |
Our current MockMemcacheClient doesn't throw an error if a key has a
space, and given MockMemcacheClient can be consumed by downstream
things, we want it to act as close to the real client as possible.
Rename _check_key to check_key_helper so we aren't importing a private
function.
|
| |
|
| |
pass the encoding from the hashed client to the pooled client when use_pooling is True.
|
| | |
|