30 |
31 | Memcached is an in-memory key-value store for small chunks of arbitrary data
32 | (strings, objects) from results of database calls, API calls, or page rendering..
33 | The Memcached integration is built on top of the spymemcached client, written by Dustin Sallings.
34 | Users that want to use Memcached into their applications, have to download the
35 | zip bundle, decompress it and add the jars in the classpath;
36 | Apache Maven users instead can simply add in
37 | the pom.xml the following dependency:
38 |
39 | ...
40 |
41 | ${project.groupId}
42 | ${project.artifactId}
43 | ${project.version}
44 |
45 | ...
46 | ]]>
47 | then, just configure it in the mapper XML
48 |
49 |
50 | ...
51 | ]]>
52 |
53 | The Memcached cache is configurable by putting the
54 | /memcached.properties classpath resource; if not found, the client will
55 | use the default setting.
56 | The following table resumes the supported configurations params; each
57 | parameter is optional, if not found in the configuration, the client will use
58 | the default value:
59 |
60 |
61 |
62 | | Property |
63 | Default |
64 | Description |
65 |
66 |
67 | | org.mybatis.caches.memcached.keyprefix |
68 | _mybatis_ |
69 | any string identifier |
70 |
71 |
72 | | org.mybatis.caches.memcached.servers |
73 | localhost:11211 |
74 | space separated list of ${host}:${port} |
75 |
76 |
77 | | org.mybatis.caches.memcached.connectionfactory |
78 | net.spy.memcached.DefaultConnectionFactory |
79 | Any class that implements net.spy.memcached.ConnectionFactory |
80 |
81 |
82 | | org.mybatis.caches.memcached.expiration |
83 | the number of seconds in 30 days |
84 | the expiration time (in seconds) |
85 |
86 |
87 | | org.mybatis.caches.memcached.asyncget |
88 | false |
89 | flag to enable/disable the async get |
90 |
91 |
92 | | org.mybatis.caches.memcached.timeout |
93 | 5 |
94 | the timeout when using async get |
95 |
96 |
97 | | org.mybatis.caches.memcached.timeoutunit |
98 | java.util.concurrent.TimeUnit.SECONDS |
99 | the timeout unit when using async get |
100 |
101 |
102 | | org.mybatis.caches.memcached.compression |
103 | false |
104 | if true, objects will be GZIP compressed before putting them to Memcached |
105 |
106 |
107 |
108 | If users need to log cache operations, they can plug the Cache logging version:
109 |
110 |
111 | ...
112 | ]]>
113 |
114 |
115 |
116 |