@Override
    public synchronized Collection<User> getUsers() {
        if (allUsers != null && allUserCacheExpires.isAfter(Instant.now())) {
            return allUsers;
        }
        this.allUsers = getUsers( -1, -1 );
        // When all user have been fetched, we can update various other cached values.
        this.userCount = this.allUsers.size();
        this.allUsernames = allUsers.stream().map(User::getUsername).collect(Collectors.toList());
        this.allUserCacheExpires = Instant.now().plus(5, ChronoUnit.MINUTES);
        return allUsers;
    }
LDAP implementation of the UserProvider interface. All data in the directory is
treated as read-only so any set operations will result in an exception.

@author Matt Tucker
xmppserver/src/main/java/org/jivesoftware/openfire/ldap/LdapUserProvider.java