Geode in 5 minutes

How to Get Apache Geode

You can download Apache Geode from the website, run a Docker image, or install with homebrew on OSX. Application developers can load dependencies from Maven Central.

您可以从网站下载 Apache Geode, 运行 docker 映像, 或在 osx 上使用自制安装。应用程序开发人员可以从 maven central 加载依赖项。

Maven

<dependencies>    
   <dependency>        
      <groupId>org.apache.geode</groupId>
      <artifactId>geode-core</artifactId>
      <version>$VERSION</version>
   </dependency>
 </dependencies>

Gradle

dependencies {  compile "org.apache.geode:geode-core:$VERSION"}

Start the cluster 启动集群

Download Geode by following one of the methods described above, and follow the installation instructions at in the posted manual at http://geode.apache.org/docs/. With a path that contains the bin directory of the installation, start a locator and server:

按照上述方法之一下载 Geode, 并按照 http://geode.apache.org/docs/张贴的手册中的安装说明进行操作。
使用包含安装的 bin 目录的路径, 启动定位器和服务:

$ gfsh
  gfsh> start locator
  gfsh> start server

Create a region:

gfsh> create region --name=hello --type=REPLICATE 

src/main/java/HelloWorld.java

package com.tom.learning.geode;

import org.apache.geode.cache.Region;
import org.apache.geode.cache.client.ClientCache;
import org.apache.geode.cache.client.ClientCacheFactory;
import org.apache.geode.cache.client.ClientRegionShortcut;

public class HelloWorld {

    public static void main(String[] args) {

        ClientCache cache = new ClientCacheFactory().addPoolLocator("localhost", 10334).create();
        Region<String, String> region = cache.<String, String>createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY).create("hello");

        region.put("1", "hello");
        region.put("2", "world");

        region.entrySet().stream().forEach(entry -> {
            System.out.format("key = %s, value = %s \n", entry.getKey(), entry.getValue());
        });

        cache.close();
    }
}

Build and run the HelloWorld example.
构建并运行 HelloWorld.

The application will connect to the running cluster, create a local cache, put some data in the cache, and print the cached data to the console:
程序运行后将连接正在运行的集群,创建本地缓存,在缓存中放置一些数据,并将缓存数据打印到控制台:

key = 1, value = hello 
key = 2, value = world 

Finally, shutdown the Geode server and locator:
最后,关闭 Geode 服务和 locator:

gfsh> shutdown --include-locators=true

For more information see the Geode Examples repository or the documentation .
查看更多信息,请查看 Geode Examples 或者文档

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值