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: devnetNo Persistence
Memcached stores data in memory only - restarting clears all cached data!
Connection Information
From Docker Containers
# Telnet test
telnet damp-memcached 11211Laravel .env:
CACHE_DRIVER=memcached
MEMCACHED_HOST=damp-memcached
MEMCACHED_PORT=11211From Host Machine
telnet localhost 11211Connection:
Host: localhost
Port: 11211Laravel Setup
Install PHP Extension
# In your devcontainer
pecl install memcachedConfiguration
// 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!