Esempio n. 1
0
  @Before
  public void setup() throws MemcachedOperationException, LockTimeoutException {
    Configure configure = new Configure();
    configure.setFullTextHashFunction(Digest.MD5);
    configure.setMecabrc("/opt/local/etc/mecabrc");
    configure.setMemcached("localhost:11211");
    configure.setMaxConnectionPoolSize(10);
    configure.setNodeFilter(MecabHashing.Filter.Nouns);
    configure.setPoolBehaviors(
        new HashMap<BehaviorType, Boolean>() {
          private static final long serialVersionUID = 1L;

          {
            put(BehaviorType.SUPPORT_CAS, Boolean.TRUE);
            put(BehaviorType.TCP_KEEPALIVE, Boolean.TRUE);
            put(BehaviorType.TCP_NODELAY, Boolean.TRUE);
            put(BehaviorType.BUFFER_REQUESTS, Boolean.FALSE);
          }
        });

    pooling = new Pooling(configure);
    pooling.init();

    ctx = new FunctionContext();
    ctx.setHashFunction(configure.getFullTextHashFunction());
    ctx.setNodeFilter(configure.getNodeFilter());
    ctx.setPooling(pooling);
    ctx.setTagger(Tagger.create("-r " + configure.getMecabrc()));

    MemcachedList list = new MemcachedList(pooling.getConnectionPool());
    for (int i = 0; i < 10; ++i) {
      // value starts: 1, ends: 10
      list.add("hoge:0", Integer.toString(i + 1), 0);
    }
  }
Esempio n. 2
0
 @After
 public void cleanup() {
   pooling.getConnectionPool().get().getStorage().flush(0);
 }