Return to Misconfigured, Redis, Valkey (Redis's successor as a free software project), Conflict-free replicated data type, Memcached, Infinispan
Memcached is a high-performance, distributed memory caching system. It's designed to speed up dynamic web applications by alleviating database load. It achieves this by storing frequently accessed data and objects in RAM, reducing the number of times an external data source, like a database, must be read.
1. **Setting and Getting a Value (Python):**
```python import memcache
mc = memcache.Client(['127.0.0.1:11211'])
mc.set('key', 'value') # Store a key-value pair value = mc.get('key') # Retrieve the value print(value) # Output: 'value' ```
2. **Setting an Expiration Time (Python):**
```python import memcache
mc = memcache.Client(['127.0.0.1:11211'])
mc.set('key', 'value', time=3600) # Store a key-value pair with an expiration time of 1 hour ```
3. **Incrementing a Counter (Node.js):**
```javascript const Memcached = require('memcached');
const memcached = new Memcached('127.0.0.1:11211');
memcached.incr('counter', 1, (err, result) ⇒ {
if (err) {
console.error(err);
} else {
console.log(result); // Output: the new value of the counter
}
});
```
These examples illustrate how to use basic Memcached operations like setting, getting, and incrementing values using different client libraries.
Memcached (pronounced either /mɛmkæʃˈdiː/ mem-cash-DEE ["dee/d" being for daemon], or /ˈmɛmkæʃt/ MEM-cashed) is a general-purpose distributed memory-caching system. It is often used to speed up dynamic database-driven websites by caching data and objects in RAM to reduce the number of times an external data source (such as a database or API) must be read. Memcached is free and open-source software, licensed under the Revised BSD license. Memcached runs on Unix-like operating systems (Linux and macOS) and on Microsoft Windows. It depends on the libevent library.
Memcached's APIs provide a large hash table distributed across multiple machines. When the table is full, subsequent inserts cause older data to be purged in least recently used (LRU) order. Applications using Memcached typically layer requests and additions into RAM before falling back on a slower backing store, such as a database.
Memcached has no internal mechanism to track misses which may happen. However, some third party utilities provide this functionality.
Memcached was first developed by Brad Fitzpatrick for his website LiveJournal, on May 22, 2003. It was originally written in Perl, then later rewritten in C by Anatoly Vorobey, who was employed by LiveJournal at the time. Memcached is now used by many other systems, including YouTube, Reddit, Facebook, Pinterest, Twitter, Wikipedia, and Method Studios. Google App Engine, Google Cloud Platform, Microsoft Azure, IBM Bluemix and Amazon Web Services also offer a Memcached service through an API.
Redis: Redis Glossary, GitHub Redis, Awesome Redis. (navbar_redis)
Cloud Monk is Retired ( for now). Buddha with you. © 2025 and Beginningless Time - Present Moment - Three Times: The Buddhas or Fair Use. Disclaimers
SYI LU SENG E MU CHYWE YE. NAN. WEI LA YE. WEI LA YE. SA WA HE.