Package net.greghaines.jesque.meta

Examples of net.greghaines.jesque.meta.KeyInfo


            }
            return keyInfo;
        }

        protected KeyInfo handleString(final Jedis jedis) {
            final KeyInfo keyInfo = new KeyInfo(this.key, KeyType.STRING);
            keyInfo.setSize(jedis.strlen(this.key));
            if (this.doArrayValue) {
                final List<String> arrayValue = new ArrayList<String>(1);
                arrayValue.add(jedis.get(this.key));
                keyInfo.setArrayValue(arrayValue);
            }
            return keyInfo;
        }
View Full Code Here


            }
            return keyInfo;
        }

        protected KeyInfo handleSet(final Jedis jedis) {
            final KeyInfo keyInfo = new KeyInfo(this.key, KeyType.SET);
            keyInfo.setSize(jedis.scard(this.key));
            if (this.doArrayValue) {
                final List<String> allMembers = new ArrayList<String>(jedis.smembers(this.key));
                if (this.offset >= allMembers.size()) {
                    keyInfo.setArrayValue(new ArrayList<String>(1));
                } else {
                    final int toIndex = (this.offset + this.count > allMembers.size())
                            ? allMembers.size()
                            : (this.offset + this.count);
                    keyInfo.setArrayValue(new ArrayList<String>(
                            allMembers.subList(this.offset, toIndex)));
                }
            }
            return keyInfo;
        }
View Full Code Here

            }
            return keyInfo;
        }

        protected KeyInfo handleList(final Jedis jedis) {
            final KeyInfo keyInfo = new KeyInfo(this.key, KeyType.LIST);
            keyInfo.setSize(jedis.llen(this.key));
            if (this.doArrayValue) {
                keyInfo.setArrayValue(jedis.lrange(this.key, this.offset, this.offset + this.count));
            }
            return keyInfo;
        }
View Full Code Here

            }
            return keyInfo;
        }

        protected KeyInfo handleHash(final Jedis jedis) {
            final KeyInfo keyInfo = new KeyInfo(this.key, KeyType.HASH);
            keyInfo.setSize(jedis.hlen(this.key));
            if (this.doArrayValue) {
                final List<String> allFields = new ArrayList<String>(jedis.hkeys(this.key));
                if (this.offset >= allFields.size()) {
                    keyInfo.setArrayValue(new ArrayList<String>(1));
                } else {
                    final int toIndex = (this.offset + this.count > allFields.size())
                            ? allFields.size()
                            : (this.offset + this.count);
                    final List<String> subFields = allFields.subList(this.offset, toIndex);
                    final List<String> values = jedis.hmget(this.key,
                            subFields.toArray(new String[subFields.size()]));
                    final List<String> arrayValue = new ArrayList<String>(subFields.size());
                    for (int i = 0; i < subFields.size(); i++) {
                        arrayValue.add("{" + subFields.get(i) + "=" + values.get(i) + "}");
                    }
                    keyInfo.setArrayValue(arrayValue);
                }
            }
            return keyInfo;
        }
View Full Code Here

TOP

Related Classes of net.greghaines.jesque.meta.KeyInfo

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.