Configure Run Sample Coherence Cache Client Application

Configure Run Sample Coherence Cache Client Application

In previous tutorial you saw:

Today you will see how to run coherence cache client application.

  • To run cache client applcation make sure cache server is started using How to test Coherence Installation tutorial
  • Set java system java path if you are not sure how to set java path please follow this tutorial
  • cd to C:\Oracle\Middleware\Oracle_Home\coherence\bin
  • open query.cmd file and add COHERENCE_HOME path based on your cache install location
@echo off
@
@rem This will start a console application
@rem demonstrating the functionality of the Coherence(tm) API
@
setlocal

:config
@rem specify the Coherence installation directory
set coherence_home=C:\Oracle\Middleware\Oracle_Home\coherence

@rem specify the jline installation directory
set jline_home=%coherence_home%\lib

@rem specify if the console will also act as a server
set storage_enabled=false

@rem specify the JVM heap size
set memory=64m


:start
if not exist "%coherence_home%\lib\coherence.jar" goto instructions

set java_home=%java_home:"=%

if "%java_home%"=="" (set java_exec=java) else (set "java_exec=%java_home%\bin\java")

:launch

if "%storage_enabled%"=="true" (echo ** Starting storage enabled console **) else (echo ** Starting storage disabled console **)

set java_opts="-Xms%memory% -Xmx%memory% -Dtangosol.coherence.distributed.localstorage=%storage_enabled%"

"%java_exec%" -server -showversion "%java_opts%" -cp "%coherence_home%\lib\coherence.jar;%jline_home%\jline.jar" com.tangosol.coherence.dslquery.QueryPlus %*

goto exit

:instructions

echo Usage:
echo   ^<coherence_home^>\bin\query.cmd
goto exit

:exit
endlocal
@echo on
  • Execute query.cmd as below:

Configure Run Sample Coherence Cache Client Application

  • You will see below output with CohQL> prompt displayed:

Configure Run Sample Coherence Cache Client Application

Now start exercise with sample cache client application using below command:

  • create cache “products”
  • insert into “products” key “television” value “ID-5070”
  • update “products” set value() = “ID-5080” where key() like “television”
  • select * from “products”
  • select key(), value() from “products” where key() is “radio”
  • delete from “products” where key() = “television”
  • delete from “products”
  • drop cache “products”
  • create cache “products”
  • insert into “products” key “television” value “ID-5080”
  • insert into “products” key “radio” value “ID-5090”
  • insert into “products” key “MP3 Player” value “ID-5100”
  • insert into “products” key “laptop” value “ID-5110”
  • select key(), value() from “products”
  • backup cache “products” to “products.bkup”
  • delete from “products” where key() = “television”
  • select key(), value() from “products”
  • delete from “products”
  • select * from “products”
  • restore cache “products” from file “products.bkup”
  • select key(), value() from “products”
  • drop cache “products”

Exit the command-line tool:

  • bye

Sample commands:

Configure Run Sample Coherence Cache Client Application

  • For more information please visit this oracle official tutorial

Leave a Reply

Your email address will not be published. Required fields are marked *