Thomas Waldmann avatar Thomas Waldmann committed cf1c853

remove memcached store - does not support iteration over keys, non-persistent (we can us it as cache, but not as store)

Comments (0)

Files changed (2)

storage/stores/_tests/test_memcached.py

-# Copyright: 2011 MoinMoin:ThomasWaldmann
-# License: GNU GPL v2 (or any later version), see LICENSE.txt for details.
-
-"""
-MoinMoin - memcached "store" (cache) tests
-
-Note: you need to have a memcached running on localhost:11211 for the tests
-      to succeed. If you don't, you'll see failures due to key errors.
-"""
-
-
-from __future__ import absolute_import, division
-
-from ..memcached import BytesStore, FileStore
-
-from . import BytesStoreTestBase, FileStoreTestBase
-
-
-class TestBytesStore(BytesStoreTestBase):
-    def setup_method(self, method):
-        self.st = BytesStore()
-        self.st.create()
-        self.st.open()
-
-    def test_iter(self):
-        """
-        memcached does not support iteration
-        """
-
-    def test_len(self):
-        """
-        memcached does not support iteration
-        """
-
-class TestFileStore(FileStoreTestBase):
-    def setup_method(self, method):
-        self.st = FileStore()
-        self.st.create()
-        self.st.open()
-
-    def test_iter(self):
-        """
-        memcached does not support iteration
-        """
-
-    def test_len(self):
-        """
-        memcached does not support iteration
-        """
-

storage/stores/memcached.py

-# Copyright: 2011 MoinMoin:ThomasWaldmann
-# License: GNU GPL v2 (or any later version), see LICENSE.txt for details.
-
-"""
-MoinMoin - memcached store
-
-This stores k/v pairs into a server using the memcached protocol.
-
-Note:
-
-- does not support iteration.
-- if the remote server uses memory (RAM), this is non-persistent!
-  memcached uses RAM, but there might be other servers using same protocol
-  using a persistent storage.
-"""
-
-
-from __future__ import absolute_import, division
-
-from StringIO import StringIO
-
-import memcache
-
-from . import MutableStoreBase, BytesMutableStoreBase, FileMutableStoreBase
-
-
-class _Store(MutableStoreBase):
-    """
-    A simple dict-based in-memory store. No persistence!
-    """
-    @classmethod
-    def from_uri(cls, uri):
-        return cls([uri])
-
-    def __init__(self, servers=['localhost:11211'], debug=0):
-        """
-        :param servers: list of memcached servers (default: ['localhost:11211'])
-        :param debug: debug parameter given to memcache.Client (default: 0)
-        """
-        self.servers = servers
-        self.debug = debug
-
-    def create(self):
-        pass
-
-    def destroy(self):
-        pass
-
-    def open(self):
-        self._mc = memcache.Client(self.servers, debug=self.debug)
-
-    def close(self):
-        self._mc.disconnect_all()
-
-    def __iter__(self):
-        # memcached does not support this
-        return iter([])
-
-    def __delitem__(self, key):
-        self._mc.delete(key)
-
-
-class BytesStore(_Store, BytesMutableStoreBase):
-    def __getitem__(self, key):
-        value = self._mc.get(key)
-        if value is None:
-            raise KeyError(key)
-        return value
-
-    def __setitem__(self, key, value):
-        self._mc.set(key, value)
-
-
-class FileStore(_Store, FileMutableStoreBase):
-    def __getitem__(self, key):
-        value = self._mc.get(key)
-        if value is None:
-            raise KeyError(key)
-        return StringIO(value)
-
-    def __setitem__(self, key, stream):
-        self._mc.set(key, stream.read())
-
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.