Package com.thimbleware.jmemcached

Examples of com.thimbleware.jmemcached.LocalCacheElement


      // Fill in all the elements of the command
      int size = Integer.parseInt(parts.get(4));
      int expire = Integer.parseInt(parts.get(3));
      int flags = Integer.parseInt(parts.get(2));
      cmd.element = new LocalCacheElement(parts.get(1), flags,
          expire != 0 && expire < CacheElement.THIRTY_DAYS ? LocalCacheElement.Now() + expire : expire, 0L);

      // look for cas and "noreply" elements
      if (numParts > 5) {
        int noreply = cmdType == Command.CAS ? 6 : 5;
View Full Code Here


                short flags = (short) (extrasBuffer.capacity() != 0 ? extrasBuffer.readUnsignedShort() : 0);

                // the remainder of the message -- that is, totalLength - (keyLength + extraLength) should be the payload
                int size = totalBodyLength - keyLength - extraLength;

                cmdMessage.element = new LocalCacheElement(key, flags, expire != 0 && expire < CacheElement.THIRTY_DAYS ? LocalCacheElement.Now() + expire : expire, 0L);
                cmdMessage.element.setData(new byte[size]);
                channelBuffer.readBytes(cmdMessage.element.getData(), 0, size);
            } else if (cmdType == Command.INCR || cmdType == Command.DECR) {
                long initialValue = extrasBuffer.readUnsignedInt();
                long amount = extrasBuffer.readUnsignedInt();
View Full Code Here

                AbstractQueue<byte[]> sizeQueue = getClientQueue(clientInfo[1]);
                if (sizeQueue == null) {
                    return null;
                }
                int size = sizeQueue.size();
                LocalCacheElement element = new LocalCacheElement(keystring, 0, 0, 0);
                element.setData(String.valueOf(size).getBytes());
                return element;
            } catch (Exception e) {
                log.error("getsize " + keystring + "error", e);
                return null;
            }
        }
        // 清空队列中所有的元素
        if (keystring.startsWith("clear")) {
            try {
                // clear|bbs|pass
                String[] clientInfo = QueueClient.parse(keystring, '|');
                if (clientInfo.length < 3 || valid(clientInfo[1], clientInfo[2]) == false) {
                    throw new ClientException("Authorization error");
                }
                AbstractQueue<byte[]> queue = getClientQueue(clientInfo[1]);
                queue.clear();
                LocalCacheElement element = new LocalCacheElement(keystring, 0, 0, 0);
                element.setData(String.valueOf(queue.size()).getBytes());
                return element;
            } catch (Exception e) {
                log.error("getsize " + keystring + "error", e);
                return null;
            }
        }
        // 重新加载权限信息
        if (keystring.startsWith("reload")) {
            try {
                // reload|bbs|pass
                String[] clientInfo = QueueClient.parse(keystring, '|');
                if (clientInfo.length < 3 || valid(clientInfo[1], clientInfo[2]) == false) {
                    throw new ClientException("Authorization error");
                }
                reloadAuthorization();
                LocalCacheElement element = new LocalCacheElement(keystring, 0, 0, 0);
                element.setData("reloadAuthorization".getBytes());
                return element;
            } catch (ConfigException e) {
                log.error(e.getMessage(), e);
            } catch (Exception e) {
                log.error("reloadAuthorization error", e);
View Full Code Here

            String[] clientInfo = QueueClient.parseWithCache(keystring);
            if (valid(clientInfo[0], clientInfo[1])) {
                byte[] data;
                data = getClientQueue(clientInfo[0]).poll();
                if (data != null) {
                    LocalCacheElement element = new LocalCacheElement(keystring, 0, 0, 0);
                    element.setData(data);
                    return element;
                } else {
                    log.info("queue empty");
                }
            } else {
View Full Code Here

TOP

Related Classes of com.thimbleware.jmemcached.LocalCacheElement

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.