innodb_memcached_config.sql 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. create database innodb_memcache;
  2. use innodb_memcache;
  3. -- ------------------------------------------------------------------------
  4. -- Following are set of "configuration tables" that used to configure
  5. -- the InnoDB Memcached.
  6. -- ------------------------------------------------------------------------
  7. -- ------------------------------------------------------------------------
  8. -- Table `cache_policies`
  9. --
  10. -- Each record in this table represents a named caching policy, specifying:
  11. -- * How the memcache GET command is executed, including whether to get
  12. -- records from local cache only, from InnoDB only, from local cache if
  13. -- present (treating InnoDB as a backing store), or not at all.
  14. -- * Similarly, how memcache SET commands are executed.
  15. -- * How memcache DELETE commands are executed.
  16. -- * Whether flushing the cache should cause a mass delete from NDB.
  17. --
  18. -- ------------------------------------------------------------------------
  19. CREATE TABLE IF NOT EXISTS `cache_policies` (
  20. `policy_name` VARCHAR(40) PRIMARY KEY,
  21. `get_policy` ENUM('innodb_only', 'cache_only', 'caching','disabled')
  22. NOT NULL ,
  23. `set_policy` ENUM('innodb_only', 'cache_only','caching','disabled')
  24. NOT NULL ,
  25. `delete_policy` ENUM('innodb_only', 'cache_only', 'caching','disabled')
  26. NOT NULL,
  27. `flush_policy` ENUM('innodb_only', 'cache_only', 'caching','disabled')
  28. NOT NULL
  29. ) ENGINE = innodb;
  30. -- ------------------------------------------------------------------------
  31. -- Table `containers`
  32. --
  33. -- A container record describes an InnoDB table used for data storage by
  34. -- InnoDB Memcache.
  35. -- There must be a unique index on the `key column`, and unique index name
  36. -- is specified in the `unique_idx_name_on_key` column of the table
  37. -- `value_columns` are comma-separated lists of the columns that make up
  38. -- the memcache key and value. Each column width is defined such that they
  39. -- are in consistent with NDB memcached.
  40. -- ------------------------------------------------------------------------
  41. CREATE TABLE IF NOT EXISTS `containers` (
  42. `name` varchar(50) not null primary key,
  43. `db_schema` VARCHAR(250) NOT NULL,
  44. `db_table` VARCHAR(250) NOT NULL,
  45. `key_columns` VARCHAR(250) NOT NULL,
  46. `value_columns` VARCHAR(250),
  47. `flags` VARCHAR(250) NOT NULL DEFAULT "0",
  48. `cas_column` VARCHAR(250),
  49. `expire_time_column` VARCHAR(250),
  50. `unique_idx_name_on_key` VARCHAR(250) NOT NULL
  51. ) ENGINE = InnoDB;
  52. CREATE TABLE IF NOT EXISTS `config_options` (
  53. `name` varchar(50) not null primary key,
  54. `value` varchar(50)) ENGINE = InnoDB;
  55. -- ------------------------------------------------------------------------
  56. -- This is an example
  57. -- We create a InnoDB table `demo_test` is the `test` database
  58. -- and insert an entry into contrainers' table to tell InnoDB Memcache
  59. -- that we has such InnoDB table as back store:
  60. -- c1 -> key
  61. -- c2 -> value
  62. -- c3 -> flags
  63. -- c4 -> cas
  64. -- c5 -> exp time
  65. -- PRIMARY -> use primary key to search
  66. -- ------------------------------------------------------------------------
  67. INSERT INTO containers VALUES ("aaa", "test", "demo_test",
  68. "c1", "c2", "c3", "c4", "c5", "PRIMARY");
  69. INSERT INTO cache_policies VALUES("cache_policy", "innodb_only",
  70. "innodb_only", "innodb_only", "innodb_only");
  71. INSERT INTO config_options VALUES("separator", "|");
  72. INSERT INTO config_options VALUES("table_map_delimiter", ".");
  73. USE test
  74. -- ------------------------------------------------------------------------
  75. -- Key (c1) must be VARCHAR or CHAR type, memcached supports key up to 255
  76. -- Bytes
  77. -- Value (c2) must be VARCHAR or CHAR type
  78. -- Flag (c3) is a 32 bits integer
  79. -- CAS (c4) is a 64 bits integer, per memcached define
  80. -- Exp (c5) is again a 32 bits integer
  81. -- ------------------------------------------------------------------------
  82. CREATE TABLE demo_test (c1 VARCHAR(32),
  83. c2 VARCHAR(1024),
  84. c3 INT, c4 BIGINT UNSIGNED, c5 INT, primary key(c1))
  85. ENGINE = INNODB;
  86. INSERT INTO demo_test VALUES ("AA", "HELLO, HELLO", 8, 0, 0);