ringles commented on a change in pull request #7403: URL: https://github.com/apache/geode/pull/7403#discussion_r832342667
########## File path: geode-for-redis/src/main/java/org/apache/geode/redis/internal/data/RedisList.java ########## @@ -127,50 +127,139 @@ private int getArrayIndex(int listIndex) { } /** - * @param elementsToAdd elements to add to this set; NOTE this list may by modified by this call - * @param region the region this instance is stored in - * @param key the name of the set to add to - * @param onlyIfExists if true then the elements should only be added if the key already exists - * and holds a list, otherwise no operation is performed. - * @return the length of the list after the operation - */ - public long lpush(List<byte[]> elementsToAdd, Region<RedisKey, RedisData> region, RedisKey key, - final boolean onlyIfExists) { - elementsPush(elementsToAdd); - storeChanges(region, key, new AddByteArrays(elementsToAdd)); + * @return the number of elements in the list + **/ + public int llen() { return elementList.size(); } /** * @param region the region this instance is stored in - * @param key the name of the set to add to + * @param key the name of the list to add to * @return the element actually popped */ public byte[] lpop(Region<RedisKey, RedisData> region, RedisKey key) { - byte[] popped = elementRemove(0); - RemoveElementsByIndex removed = new RemoveElementsByIndex(); - removed.add(0); + byte newVersion; + byte[] popped; + RemoveElementsByIndex removed; + synchronized (this) { + newVersion = incrementAndGetVersion(); + popped = removeFirstElement(); + removed = new RemoveElementsByIndex(newVersion); + removed.add(0); + } storeChanges(region, key, removed); return popped; } + public synchronized byte[] removeFirstElement() { + return elementList.removeFirst(); + } + + public synchronized byte[] removeLastElement() { + return elementList.removeLast(); + } + /** - * @return the number of elements in the list + * @param elementsToAdd elements to add to this list; NOTE this list may be modified by this call + * @param region the region this instance is stored in + * @param key the name of the list to add to + * @param onlyIfExists if true then the elements should only be added if the key already exists + * and holds a list, otherwise no operation is performed. + * @return the length of the list after the operation */ - public int llen() { + public long lpush(List<byte[]> elementsToAdd, Region<RedisKey, RedisData> region, RedisKey key, + final boolean onlyIfExists) { + byte newVersion; Review comment: Mooted by rebase. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@geode.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org