刚才执行的innodb_memcached_config.sql脚本会产生innodb_memcache库和三个表cache_policies, config_options, containers. mysql> use innodb_memcache Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A
Database changed mysql> mysql> show tables; +---------------------------+ | Tables_in_innodb_memcache | +---------------------------+ | cache_policies | | config_options | | containers | +---------------------------+ 3 rows in set (0.00 sec)
mysql> desc cache_policies; +---------------+-------------------------------------------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +---------------+-------------------------------------------------------+------+-----+---------+-------+ | policy_name | varchar(40) | NO | PRI | NULL | | | get_policy | enum('innodb_only','cache_only','caching','disabled') | NO | | NULL | | | set_policy | enum('innodb_only','cache_only','caching','disabled') | NO | | NULL | | | delete_policy | enum('innodb_only','cache_only','caching','disabled') | NO | | NULL | | | flush_policy | enum('innodb_only','cache_only','caching','disabled') | NO | | NULL | | +---------------+-------------------------------------------------------+------+-----+---------+-------+ 5 rows in set (0.09 sec)
mysql> desc config_options; +-------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+-------------+------+-----+---------+-------+ | name | varchar(50) | NO | PRI | NULL | | | value | varchar(50) | YES | | NULL | | +-------+-------------+------+-----+---------+-------+ 2 rows in set (0.00 sec)
mysql> desc containers; +------------------------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +------------------------+--------------+------+-----+---------+-------+ | name | varchar(50) | NO | PRI | NULL | | | db_schema | varchar(250) | NO | | NULL | | | db_table | varchar(250) | NO | | NULL | | | key_columns | varchar(250) | NO | | NULL | | | value_columns | varchar(250) | YES | | NULL | | | flags | varchar(250) | NO | | 0 | | | cas_column | varchar(250) | YES | | NULL | | | expire_time_column | varchar(250) | YES | | NULL | | | unique_idx_name_on_key | varchar(250) | NO | | NULL | | +------------------------+--------------+------+-----+---------+-------+ 9 rows in set (0.00 sec)
现在我们用Memcached来查看一下 [mysql@localhost ~]$ echo "get @@aaa.AA" | nc localhost 11211 VALUE @@aaa.AA 8 12 HELLO, HELLO END
[mysql@localhost ~]$ echo "set @@aaa"; echo "get AA" | nc localhost 11211 set @@aaa VALUE AA 8 12 HELLO, HELLO END
此时set、get可以正常使用了.
现在我们来实际测试一下
mysql> use test Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A
Database changed
mysql> show tables; +----------------+ | Tables_in_test | +----------------+ | demo_test | +----------------+ 1 row in set (0.00 sec) mysql> create table emp (id int unsigned not null auto_increment,user varchar(20) not null,city varchar(20) not null,email varchar(20),work varchar(20),flags int unsigned default '0',cas_column bigint unsigned default '0', expire_time_column int unsigned default '0', primary key(id),unique key (user)); Query OK, 0 rows affected (0.28 sec)
mysql> select * from containers; +---------+-----------+-----------+-------------+------------------+-------+------------+--------------------+------------------------+ | name | db_schema | db_table | key_columns | value_columns | flags | cas_column | expire_time_column | unique_idx_name_on_key | +---------+-----------+-----------+-------------+------------------+-------+------------+--------------------+------------------------+ | aaa | test | demo_test | c1 | c2 | c3 | c4 | c5 | PRIMARY | | default | test | emp | user | city|email|email | flags | cas_column | expire_time_column | user | +---------+-----------+-----------+-------------+------------------+-------+------------+--------------------+------------------------+ 2 rows in set (0.00 sec)
现在策略已经设置完毕,现在我们通过Memcached查看一下 [mysql@localhost ~]$ echo "get efg"| nc 127.0.0.1 11211 VALUE efg 0 26 beijing|456@abc.com|farmer END [mysql@localhost ~]$ echo "get edc"| nc 127.0.0.1 11211 VALUE edc 0 25 shenzhen|789@abc.com|teacher END
现在来看看从Memcached写入数据的效果 [mysql@localhost ~]$ telnet 127.0.0.1 11211 Trying 127.0.0.1... Connected to 127.0.0.1. Escape character is '^]'. get @@aaa.AA VALUE @@aaa.AA 8 12 HELLO, HELLO END set test 0 0 4 ss STORED get test VALUE test 0 4 ss
END