Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/362.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/redis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/hibernate/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 暗启动:在脱机模式下从客户端刷新数据_Java_Redis_Launchdarkly - Fatal编程技术网

Java 暗启动:在脱机模式下从客户端刷新数据

Java 暗启动:在脱机模式下从客户端刷新数据,java,redis,launchdarkly,Java,Redis,Launchdarkly,我正在使用LaunchDarkly的Java+Redis SDK开发POC,我的需求之一是在“脱机”模式下初始化第二个LaunchDarkly客户端。由于我现有的架构,一个应用程序将连接到LaunchDarkly并添加Redis实例。第二个应用程序将连接到同一个数据存储,但客户端将初始化为“脱机”--当前是否有一种方法可以让我从脱机客户端读取存储的事件,并将其刷新到启动服务器 在下面的代码片段中,我正在初始化第一个client+redis存储,然后在连接到同一个本地redis实例的后台线程中初始

我正在使用LaunchDarkly的Java+Redis SDK开发POC,我的需求之一是在“脱机”模式下初始化第二个LaunchDarkly客户端。由于我现有的架构,一个应用程序将连接到LaunchDarkly并添加Redis实例。第二个应用程序将连接到同一个数据存储,但客户端将初始化为“脱机”--当前是否有一种方法可以让我从脱机客户端读取存储的事件,并将其刷新到启动服务器

在下面的代码片段中,我正在初始化第一个client+redis存储,然后在连接到同一个本地redis实例的后台线程中初始化第二个客户端。我可以确认,当我运行此代码段时,在LaunchDarkly UI中没有看到填充事件

注意:这是确定LaunchDarkly是否适用于我的用例的POC。它不是生产级实现

public static void main(String[] args) throws IOException {
        LDConfig config = new LDConfig.Builder().dataStore(Components
                .persistentDataStore(
                        Redis.dataStore().uri(URI.create("redis://127.0.0.1:6379")).prefix("my-key-prefix"))
                .cacheSeconds(30)).build();

        LDClient ldClient = new LDClient("SDK-KEY", config);

        Runnable r = new Runnable() {
            @Override
            public void run() {
                LDConfig offlineConfig = new LDConfig.Builder().dataStore(Components
                        .persistentDataStore(
                                Redis.dataStore().uri(URI.create("redis://127.0.0.1:6379")).prefix("my-key-prefix"))
                        .cacheSeconds(30)).offline(true).build();
                LDClient offlineClient = new LDClient("SDK-KEY", offlineConfig);

                String uniqueId = "abcde";
                LDUser user = new LDUser.Builder(uniqueId).custom("customField", "customValue").build();

                boolean showFeature = offlineClient.boolVariation("test-feature-flag", user, false);
                if (showFeature) {
                    System.out.println("Showing your feature");
                } else {
                    System.out.println("Not showing your feature");
                }

                try {
                    offlineClient.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        };

        ExecutorService executor = Executors.newCachedThreadPool();
        executor.submit(r);
        executor.shutdown();

        ldClient.close();
    }