Damp

Memcached

Distributed memory caching system

High-performance distributed memory caching system. Simple, fast, and efficient for object caching.

Default Configuration

Image: memcached:alpine
Container: damp-memcached
Port: 11211:11211
Network: devnet

No Persistence

Memcached stores data in memory only - restarting clears all cached data!

Connection Information

From Docker Containers

# Telnet test
telnet damp-memcached 11211

Laravel .env:

CACHE_DRIVER=memcached
MEMCACHED_HOST=damp-memcached
MEMCACHED_PORT=11211

From Host Machine

telnet localhost 11211

Connection:

Host: localhost
Port: 11211

Laravel Setup

Install PHP Extension

# In your devcontainer
pecl install memcached

Configuration

// config/cache.php
'memcached' => [
    'driver' => 'memcached',
    'servers' => [
        [
            'host' => env('MEMCACHED_HOST', '127.0.0.1'),
            'port' => env('MEMCACHED_PORT', 11211),
            'weight' => 100,
        ],
    ],
],

Usage Examples

// Store cache
Cache::put('key', 'value', 3600);

// Retrieve cache
$value = Cache::get('key');

// Check if exists
if (Cache::has('key')) {
    //
}

When to Use Memcached

Best For:

  • Simple key-value caching
  • Distributed caching across multiple servers
  • Session storage (in multi-server setups)

Use Redis Instead For:

  • Data persistence requirements
  • Complex data structures (lists, sets, hashes)
  • Pub/Sub messaging

Performance

Memcached is extremely fast for simple caching - perfect for storing rendered views and query results!