Skip to content
Latchkey

Memcached "SERVER_ERROR object too large for cache" in CI

Memcached rejects a value larger than its item size limit with "SERVER_ERROR object too large for cache." The default maximum item size is 1 MB; larger values need the server started with a bigger -I (max item size) limit.

What this error means

A set of a large value fails with "SERVER_ERROR object too large for cache" while smaller values store fine, because the payload exceeds the 1 MB default.

memcached
SERVER_ERROR object too large for cache

Common causes

Value exceeds the 1 MB default item size

Memcached caps a single item at 1 MB by default; a serialized object above that is refused.

The service was not started with a larger -I

The CI memcached image uses the default max item size, so large test payloads do not fit.

How to fix it

Raise the max item size

Start memcached with a larger -I so bigger items are accepted.

.github/workflows/ci.yml
services:
  memcached:
    image: memcached:1.6
    options: memcached -m 128 -I 8m
    ports: ['11211:11211']

Store smaller values

If large items are not intended, compress or split the payload so it stays under the limit.

python
# example: compress before set in the app/test
value = zlib.compress(payload)

How to prevent it

  • Set -I to fit the largest item your tests store.
  • Keep cached objects small; do not cache oversized blobs.
  • Match the CI item-size limit to production.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →