This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

The Python dictionary-based mock memcached client library. It does not connect to any memcached server, but keeps a dictionary and stores every cache into there internally. It is a just emulated API of memcached client only for tests. It implements expiration also. NOT THREAD-SAFE.

try:
    import memcache
except ImportError:
    import warnings
    import mockcache as memcache
    warnings.warn("imported mockcache instead of memcache; cannot find "
                  "memcache module")

mc = memcache.Client(["127.0.0.1:11211"])

This module and other memcached client libraries have the same behavior.

>>> from mockcache import Client
>>> mc = Client()
>>> mc
<mockcache.Client {}>
>>> mc.get("a")
>>> mc.get("a") is None
True
>>> mc.set("a", "1234")
1
>>> mc.get("a")
'1234'
>>> mc
<mockcache.Client {'a': ('1234', None)}>
>>> mc.add("a", "1111")
0
>>> mc.get("a")
'1234'
>>> mc
<mockcache.Client {'a': ('1234', None)}>
>>> mc.replace("a", "2222")
1
>>> mc.get("a")
'2222'
>>> mc
<mockcache.Client {'a': ('2222', None)}>
>>> mc.append("a", "3")
1
>>> mc.get("a")
'22223'
>>> mc
<mockcache.Client {'a': ('22223', None)}>
>>> mc.prepend("a", "1")
1
>>> mc.get("a")
'122223'
>>> mc
<mockcache.Client {'a': ('122223', None)}>
>>> mc.incr("a")
122224
>>> mc.get("a")
122224
>>> mc
<mockcache.Client {'a': (122224, None)}>
>>> mc.incr("a", 10)
122234
>>> mc.get("a")
122234
>>> mc
<mockcache.Client {'a': (122234, None)}>
>>> mc.decr("a")
122233
>>> mc.get("a")
122233
>>> mc
<mockcache.Client {'a': (122233, None)}>
>>> mc.decr("a", 5)
122228
>>> mc.get("a")
122228
>>> mc
<mockcache.Client {'a': (122228, None)}>
>>> mc.replace("b", "value")
0
>>> mc.get("b")
>>> mc.get("b") is None
True
>>> mc
<mockcache.Client {'a': (122228, None)}>
>>> mc.add("b", "value", 5)
1
>>> mc.get("b")
'value'
>>> mc  # doctest: +ELLIPSIS
<mockcache.Client {'a': (122228, None), 'b': ('value', ...)}>
>>> import time
>>> time.sleep(6)
>>> mc.get("b")
>>> mc.get("b") is None
True
>>> mc
<mockcache.Client {'a': (122228, None)}>
>>> mc.set("c", "value")
1
>>> mc.get_multi(["a", "b", "c"])
{'a': 122228, 'c': 'value'}
>>> mc.set_multi({"a": 999, "b": 998, "c": 997}, key_prefix="pf_")
[]
>>> mc.get("pf_a")
999
>>> multi_result = mc.get_multi(["b", "c"], key_prefix="pf_")
>>> multi_result["b"]
998
>>> multi_result["c"]
997
>>> mc.delete("a")
1
>>> mc.get("a") is None
True
>>> mc.set("a b c", 123) #doctest: +IGNORE_EXCEPTION_DETAIL
Traceback (most recent call last):
MockcachedKeyCharacterError: Control characters not allowed
>>> mc.set(None, 123) #doctest: +IGNORE_EXCEPTION_DETAIL
Traceback (most recent call last):
MockcachedKeyNoneError: Key is None
>>> mc.set(123, 123) #doctest: +IGNORE_EXCEPTION_DETAIL
Traceback (most recent call last):
MockcachedKeyTypeError: Key must be str()'s
>>> mc.set(u"a", 123) #doctest: +IGNORE_EXCEPTION_DETAIL
Traceback (most recent call last):
MockcachedStringEncodingError: Key must be str()'s, not unicode.
>>> mc.set("a" * 251, 123) #doctest: +IGNORE_EXCEPTION_DETAIL
Traceback (most recent call last):
MockcachedKeyLengthError: Key length is > ...
Release History

Release History

1.0.3

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.0.2

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.0.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.9

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
mockcache-1.0.3.tar.gz (4.7 kB) Copy SHA256 Checksum SHA256 Source Feb 1, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting