content_image/788105.jpg
The example assumes that the daemon_memcached  plugin is installed as described in Section 15.20.3, “Setting Up the InnoDB memcached Plugin” . It also assumes that your system is configured to run a Python script that uses the python-memcache  module. 

1. Create the multicol  table which stores country information including population, area, and driver side data ( ’R’  for right and ’L’  for left). 

mysql> USE test; mysql> CREATE TABLE ‘multicol‘ ( ‘country‘ varchar(128) NOT NULL DEFAULT ’’, ‘population‘ varchar(10) DEFAULT NULL, ‘area_sq_km‘ varchar(9) DEFAULT NULL, ‘drive_side‘ varchar(1) DEFAULT NULL, ‘c3‘ int(11) DEFAULT NULL, ‘c4‘ bigint(20) unsigned DEFAULT NULL, ‘c5‘ int(11) DEFAULT NULL, PRIMARY KEY (‘country‘) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; 

2. Insert a record into the innodb_memcache.containers  table so that the daemon_memcached plugin can access the multicol  table. 

mysql> INSERT INTO innodb_memcache.containers (name,db_schema,db_table,key_columns,value_columns,flags,cas_column, expire_time_column,unique_idx_name_on_key) VALUES (’bbb’,’test’,’multicol’,’country’,’population,area_sq_km,drive_side’, ’c3’,’c4’,’c5’,’PRIMARY’); mysql> COMMIT; 

•The innodb_memcache.containers  record for the multicol  table specifies a name  value of ’bbb’ , which is the table identifier. 

<img src='content_image/788105.jpg'>

## Note 

If a single InnoDB  table is used for all memcached  applications, the name value can be set to default  to avoid using @@  notation to switch tables. 

•The db_schema  column is set to test , which is the name of the database where the multicol table resides. 

•The db_table  column is set to multicol , which is the name of the InnoDB  table. 

• key_columns  is set to the unique country  column. The country  column is defined as the primary key in the multicol  table definition. 

•Rather than a single InnoDB  table column to hold a composite data value, data is divided among three table columns ( population , area_sq_km , and drive_side ). To accommodate multiple value columns, a comma-separated list of columns is specified in the value_columns  field. The columns defined in the value_columns  field are the columns used when storing or retrieving values. 

•Values for the flags , expire_time , and cas_column  fields are based on values used in the demo.test  sample table. These fields are typically not significant in applications that use the daemon_memcached  plugin because MySQL keeps data synchronized, and there is no need to worry about data expiring or becoming stale. 

