Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/tests-and-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ jobs:
strategy:
max-parallel: 4
matrix:
python-version: [3.8, 3.9, "3.10", 3.11, 3.12]
# Keep every version quoted. Unquoted 3.10 parses as the float 3.1.
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]

steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Generated artifacts such as `dist/`, `*.egg-info/`, and docs build outputs shoul
- `python -m pip install -e . -r requirements_test.txt`: install the package in editable mode with test and lint dependencies.
- `pytest -s`: run the test suite. Requires the `memcached` executable available on `PATH`.
- `flake8`: run style checks with the repository's `max-line-length = 120`.
- `tox`: run the full configured gate for Python 3.8 through 3.12.
- `tox`: run the full configured gate for Python 3.10 through 3.14.
- `cd docs && make html`: build Sphinx HTML documentation into `docs/_build/html`.
- `python -m build --sdist --wheel --outdir dist/ .`: build release artifacts when the `build` package is installed.

Expand Down
18 changes: 9 additions & 9 deletions bmemcached/client/distributed.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from bmemcached.client import SOCKET_TIMEOUT
from bmemcached.client.mixin import ClientMixin
from bmemcached.compat import pickle
import pickle


class DistributedClient(ClientMixin):
Expand All @@ -14,8 +14,8 @@ class DistributedClient(ClientMixin):
def __init__(self, servers=('127.0.0.1:11211',), username=None, password=None, compression=None,
socket_timeout=SOCKET_TIMEOUT, pickle_protocol=0, pickler=pickle.Pickler, unpickler=pickle.Unpickler,
tls_context=None):
super(DistributedClient, self).__init__(servers, username, password, compression, socket_timeout,
pickle_protocol, pickler, unpickler, tls_context)
super().__init__(servers, username, password, compression, socket_timeout,
pickle_protocol, pickler, unpickler, tls_context)
self._ring = HashRing(self._servers)

def _get_server(self, key):
Expand Down Expand Up @@ -125,7 +125,7 @@ def add(self, key, value, time=0, compress_level=-1, get_cas=False):
Add a key/value to server ony if it does not exist.

:param key: Key's name
:type key: six.string_types
:type key: str
:param value: A value to be stored on server.
:type value: object
:param time: Time in seconds that your key will expire.
Expand All @@ -149,7 +149,7 @@ def replace(self, key, value, time=0, compress_level=-1, get_cas=False):
Replace a key/value to server ony if it does exist.

:param key: Key's name
:type key: six.string_types
:type key: str
:param value: A value to be stored on server.
:type value: object
:param time: Time in seconds that your key will expire.
Expand All @@ -173,7 +173,7 @@ def get(self, key, default=None, get_cas=False):
Get a key from server.

:param key: Key's name
:type key: six.string_types
:type key: str
:param default: In case memcached does not find a key, return a default value
:param get_cas: If true, return (value, cas), where cas is the new CAS value.
:type get_cas: boolean
Expand Down Expand Up @@ -229,7 +229,7 @@ def cas(self, key, value, cas, time=0, compress_level=-1, get_cas=False):
Set a value for a key on server if its CAS value matches cas.

:param key: Key's name
:type key: six.string_types
:type key: str
:param value: A value to be stored on server.
:type value: object
:param cas: The CAS value previously obtained from a call to get*.
Expand All @@ -255,7 +255,7 @@ def incr(self, key, value, default=0, time=1000000):
Increment a key, if it exists, returns it's actual value, if it don't, return 0.

:param key: Key's name
:type key: six.string_types
:type key: str
:param value: Number to be incremented
:type value: int
:param default: If key not set, initialize to this value
Expand All @@ -274,7 +274,7 @@ def decr(self, key, value, default=0, time=1000000):
Minimum value of decrement return is 0.

:param key: Key's name
:type key: six.string_types
:type key: str
:param value: Number to be decremented
:type value: int
:param default: If key not set, initialize to this value
Expand Down
15 changes: 7 additions & 8 deletions bmemcached/client/mixin.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
import six

from bmemcached.client.constants import PICKLE_PROTOCOL, SOCKET_TIMEOUT
from bmemcached.compat import pickle
import pickle
from bmemcached.protocol import Protocol


class ClientMixin(object):
class ClientMixin:
""" Client mixin with basic commands.

:param servers: A list of servers with ip[:port] or unix socket.
:type servers: list
:param username: If your server requires SASL authentication, provide the username.
:type username: six.string_types
:type username: str
:param password: If your server requires SASL authentication, provide the password.
:type password: six.string_types
:type password: str
:param compression: This memcached client uses zlib compression by default,
but you can change it to any Python module that provides
`compress` and `decompress` functions, such as `bz2`.
Expand Down Expand Up @@ -65,7 +64,7 @@ def set_servers(self, servers):
:return: Returns nothing
:rtype: None
"""
if isinstance(servers, six.string_types):
if isinstance(servers, str):
servers = [servers]

assert servers, "No memcached servers supplied"
Expand Down Expand Up @@ -101,7 +100,7 @@ def stats(self, key=None):
Return server stats.

:param key: Optional if you want status from a key.
:type key: six.string_types
:type key: str
:return: A dict with server stats
:rtype: dict
"""
Expand Down Expand Up @@ -150,7 +149,7 @@ def add(self, key, value, time=0, compress_level=-1, get_cas=False):
def replace(self, key, value, time=0, compress_level=-1, get_cas=False):
raise NotImplementedError()

def delete(self, key, cas=0): # type: (six.string_types, int) -> bool
def delete(self, key, cas=0): # type: (str, int) -> bool
raise NotImplementedError()

def delete_multi(self, keys):
Expand Down
14 changes: 7 additions & 7 deletions bmemcached/client/replicating.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def get(self, key, default=None, get_cas=False):
class-level note on CAS and replication.

:param key: Key's name
:type key: six.string_types
:type key: str
:param default: In case memcached does not find a key, return a default value
:param get_cas: If true, return (value, cas), where cas is the new CAS value.
:type get_cas: boolean
Expand Down Expand Up @@ -107,7 +107,7 @@ def gets(self, key):
CAS and replication.

:param key: Key's name
:type key: six.string_types
:type key: str
:return: Returns (key data, value), or (None, None) if the value is not in cache.
:rtype: object
"""
Expand Down Expand Up @@ -207,7 +207,7 @@ def cas(self, key, value, cas, time=0, compress_level=-1, get_cas=False):
silently diverge them -- at most one replica accepts the write.

:param key: Key's name
:type key: six.string_types
:type key: str
:param value: A value to be stored on server.
:type value: object
:param cas: The CAS value previously obtained from a call to get*.
Expand Down Expand Up @@ -316,7 +316,7 @@ def add(self, key, value, time=0, compress_level=-1, get_cas=False):
Add a key/value to server ony if it does not exist.

:param key: Key's name
:type key: six.string_types
:type key: str
:param value: A value to be stored on server.
:type value: object
:param time: Time in seconds that your key will expire.
Expand Down Expand Up @@ -354,7 +354,7 @@ def replace(self, key, value, time=0, compress_level=-1, get_cas=False):
Replace a key/value to server ony if it does exist.

:param key: Key's name
:type key: six.string_types
:type key: str
:param value: A value to be stored on server.
:type value: object
:param time: Time in seconds that your key will expire.
Expand Down Expand Up @@ -413,7 +413,7 @@ def incr(self, key, value, default=0, time=1000000):
Increment a key, if it exists, returns it's actual value, if it don't, return 0.

:param key: Key's name
:type key: six.string_types
:type key: str
:param value: Number to be incremented
:type value: int
:param default: If key not set, initialize to this value
Expand All @@ -435,7 +435,7 @@ def decr(self, key, value, default=0, time=1000000):
Minimum value of decrement return is 0.

:param key: Key's name
:type key: six.string_types
:type key: str
:param value: Number to be decremented
:type value: int
:param default: If key not set, initialize to this value
Expand Down
14 changes: 0 additions & 14 deletions bmemcached/compat.py

This file was deleted.

Loading
Loading