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 或者文档。