Picking cached session

@param uid        User's id
@param keyGroupId Key Group Id
@return promise of session
166403
private Promise<PeerSession> pickCachedSession(int uid, final int keyGroupId) {
        return ManagedList.of(peerSessions.getValue(uid))
                .flatMap(PeerSessionsStorage.SESSIONS)
                .filter(PeerSession.BY_THEIR_GROUP(keyGroupId))
                .sorted(PeerSession.COMPARATOR)
                .firstPromise();
    }
344007
public static com.liferay.commerce.product.model.CPInstance getCPInstanceByUuidAndGroupId(
		String uuid, long groupId)
		throws com.liferay.portal.kernel.exception.PortalException {
		return getService().getCPInstanceByUuidAndGroupId(uuid, groupId);
	}
649361
@Override
	public CPFriendlyURLEntry removeByUUID_G(String uuid, long groupId)
		throws NoSuchCPFriendlyURLEntryException {
		CPFriendlyURLEntry cpFriendlyURLEntry = findByUUID_G(uuid, groupId);

		return remove(cpFriendlyURLEntry);
	}
966209
@Override
	public List<CProduct> findByGroupId(long groupId) {
		return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
	}
5826
@Override
	public CommerceOrder fetchCommerceOrderByUuidAndGroupId(String uuid,
		long groupId) {
		return commerceOrderPersistence.fetchByUUID_G(uuid, groupId);
	}
1046902
def fetch_group_cached(group_id, failures=True, wait=0, count=None, broker=None):
    
    if not broker:
        broker = get_broker()
    start = time()
    if count:
        while True:
            if count_group_cached(group_id) == count or wait and (time() - start) * 1000 >= wait >= 0:
                break
            sleep(0.01)
    while True:
        group_list = broker.cache.get('{}:{}:keys'.format(broker.list_key, group_id))
        if group_list:
            task_list = []
            for task_key in group_list:
                task = SignedPackage.loads(broker.cache.get(task_key))
                if task['success'] or failures:
                    t = Task(id=task['id'],
                             name=task['name'],
                             func=task['func'],
                             hook=task.get('hook'),
                             args=task['args'],
                             kwargs=task['kwargs'],
                             started=task['started'],
                             stopped=task['stopped'],
                             result=task['result'],
                             group=task.get('group'),
                             success=task['success'])
                    task_list.append(t)
            return task_list
        if (time() - start) * 1000 >= wait >= 0:
            break
        sleep(0.01)
1305335
public static com.liferay.commerce.product.model.CPDefinition fetchCPDefinitionByUuidAndGroupId(
		String uuid, long groupId) {
		return getService().fetchCPDefinitionByUuidAndGroupId(uuid, groupId);
	}
645156
private void removeAllRelatedFromCache(String groupId)
   {
      cache.remove(CacheHandler.GROUP_PREFIX + groupId, CacheType.MEMBERSHIP);
   }
1282167
public static CPFriendlyURLEntry removeByUUID_G(String uuid, long groupId)
		throws com.liferay.commerce.product.exception.NoSuchCPFriendlyURLEntryException {
		return getPersistence().removeByUUID_G(uuid, groupId);
	}
939191
@Override
    public ILockableEntityGroup findLockable(String groupID) throws GroupsException {
        return (ILockableEntityGroup) primFind(groupID, true);
    }
756579
@Override
	public CPOption fetchCPOptionByUuidAndGroupId(String uuid, long groupId) {
		return cpOptionPersistence.fetchByUUID_G(uuid, groupId);
	}
789686
@Override
	public com.liferay.commerce.product.model.CPOption fetchCPOptionByUuidAndGroupId(
		String uuid, long groupId) {
		return _cpOptionLocalService.fetchCPOptionByUuidAndGroupId(uuid, groupId);
	}
167365
public <U extends UnsortedGrouping<?>> void add(int id, U set) {
		cacheSetType(id, SetType.UNSORTED_GROUPING);
		unsortedGroupings.put(id, set);
	}
600587
private ILockableEntityGroup ifindLockableGroup(String key, String lockOwner)
            throws GroupsException {
        return compositeGroupService.findGroupWithLock(key, lockOwner);
    }
844445
@Override
	public CPInstance removeByUUID_G(String uuid, long groupId)
		throws NoSuchCPInstanceException {
		CPInstance cpInstance = findByUUID_G(uuid, groupId);

		return remove(cpInstance);
	}
1028709
function(uid, sid, groups) {
  if(!sid) {
    logger.warn('ignore uid %j for sid not specified.', uid);
    return false;
  }

  var group = groups[sid];
  if(!group) {
    group = [];
    groups[sid] = group;
  }

  group.push(uid);
  return true;
}
622700
public static synchronized UnixUserGroupInformation getUgiForUser(
      String userName) {
    long now = System.currentTimeMillis();
    long cutoffTime = now - ugiLifetime;
    CachedUgi cachedUgi = ugiCache.get(userName);
    if (cachedUgi != null && cachedUgi.getInitTime() > cutoffTime)
      return cachedUgi.getUgi();
    UnixUserGroupInformation ugi = null;
    try {
      ugi = getUgi(userName);
    } catch (IOException e) {
      return null;
    }
    if (ugiCache.size() > CLEANUP_THRESHOLD) { // remove expired ugi's first
      for (Iterator<Map.Entry<String, CachedUgi>> it = ugiCache.entrySet()
          .iterator(); it.hasNext();) {
        Map.Entry<String, CachedUgi> e = it.next();
        if (e.getValue().getInitTime() < cutoffTime) {
          it.remove();
        }
      }
    }
    ugiCache.put(ugi.getUserName(), new CachedUgi(ugi, now));
    return ugi;
  }