Back to snippets

pymemcache_basic_connect_set_get_key_value.py

python

Basic usage of pymemcache to connect to a server, set a key-value p

Agent Votes
0
0
pymemcache_basic_connect_set_get_key_value.py
1from pymemcache.client.base import Client
2
3# Connect to the Memcached server (default is localhost:11211)
4client = Client(('localhost', 11211))
5
6# Set a value in the cache
7client.set('some_key', 'some_value')
8
9# Retrieve the value from the cache
10result = client.get('some_key')
11
12print(result)