📃
Python Reference
  • Installation
  • First Steps
  • Variables
  • Operators and Expressions
  • Control Flow
  • Loops
  • Functions
  • String
  • List
  • Dictionany
  • Modules
  • Class
  • File
  • Folder
  • Module os
  • Image
  • JSON
  • XML
  • Connection MySQL
  • Connection Redis
  • Connection Memcached
  • Connection RabbitMQ
  • Restful client
  • STMP
  • Socket
Powered by GitBook
On this page
  • Cài đặt
  • Kết nối đến Memcached Server
  • Thực hiện lệnh
  • Follower me

Was this helpful?

Connection Memcached

PreviousConnection RedisNextConnection RabbitMQ

Last updated 4 years ago

Was this helpful?

Memcached là một memory cache server thông dụng hiện nay. Nội dung chương này sẽ hướng dẫn bạn kết nối đến một Memcached server (đã được cài đặt sẵn) thông qua thư viện pylibmc.

Cài đặt

Có thể xem thêm về hướng dẫn cài đặt thư viện này tại

Đơn giản cài thông qua pip là:

$ sudo pip install pylibmc

Kết nối đến Memcached Server

Để kết nối đến Memcached server thì bạn có thể xem ví dụ sau:

Ví dụ:

import pylibmc

mc = pylibmc.Client(["127.0.0.1"], binary=True, behaviors={"tcp_nodelay": True, "ketama": True})

Thực hiện lệnh

Thực hiện các lệnh bình thường trên đối tượng memcache.

Ví dụ:

import pylibmc

mc = pylibmc.Client(...)
mc.set('foo', 'bar')
print mc.get('foo')
# Hiển thị 'bar'

Follower me

Facebook:

Blog:

Github:

http://sendapatch.se/projects/pylibmc/install.html
https://www.facebook.com/lamsaodecode
https://lamsaodecode.blogspot.com
https://lamsaodecode.github.io/introduction