Package: coherence-client
Coherence Python ClientThe Coherence Python Client allows Python applications to act as cache clients to an Oracle Coherence cluster using gRPC as the network transport.FeaturesFamiliar Map-like interface for manipulating cache entries including but not limited to:put,put_if_absent,put_all,get,get_all,remove,clear,get_or_default,replace,replace_mapping,size,is_empty,contains_key,contains_valueCluster-side querying, aggregation and filtering of map entriesCluster-side manipulation of map entries using EntryProcessorsRegistration of listeners to be notified of:mutations such as insert, update and delete on Mapsmap lifecycle events such as truncated, released or destroyedsession lifecycle events such as connected, disconnected, reconnected and closedSupport for storing Python objects as JSON as well as the ability to serialize to Java objects on the server for access from other Coherence language API'sRequirementsCoherence CE22.06.4+ or Coherence 14.1.1.2206.4+ Commercial edition with a configuredgRPCProxy.Python 3.11.xStarting a Coherence ClusterBefore testing the Python client, you must ensure a Coherence cluster is available.
For local development, we recommend using the Coherence CE Docker image; it contains
everything necessary for the client to operate correctly.dockerrun-d-p1408:1408ghcr.io/oracle/coherence-ce:22.06.5Installationpython3-mpipinstallcoherence-clientDocumentationhttps://oracle.github.io/coherence-py-client/ExamplesThe following example connects to a Coherence cluster running gRPC Proxy on default
port of 1408, creates a newNamedCachewith keystrand value of astr|intand
issuesput(),get(),size()andremoveoperations.fromcoherenceimportNamedCache,Sessionimportasyncioasyncdefrun_test():# create a new Session to the Coherence serversession:Session=awaitSession.create()# create a new NamedCache with key of string|int and value of string|intcache:NamedCache[str,str|int]=awaitsession.get_cache("test")# put a new key/valuek:str="one"v:str="only-one"awaitcache.put(k,v)# get the value for a key in the cacher=awaitcache.get(k)# print the value got for a key in the cacheprint("The value of key\"one\"is "+r)k1:str="two"v1:int=2awaitcache.put(k1,v1)r=awaitcache.get(k1)print("The value of key\"two\"is "+str(r))# print the size of the cacheprint("Size of the cache test is "+str(awaitcache.size()))# remove an entry from the cacheawaitcache.remove(k1)# run the testasyncio.run(run_test())HelpWe have apublic Slack channelwhere you can get in touch with us to ask questions about using the Coherence CLI
or give us feedback or suggestions about what features and improvements you would like to see. We would love
to hear from you. To join our channel,
pleasevisit this site to get an invitation.
The invitation email will include details of how to access our Slack
workspace.  After you are logged in, please come to#coherenceand say, "hello!"If you would like to raise an issue please seehere.ContributingThis project welcomes contributions from the community. Before submitting a pull request, pleasereview our contribution guideSecurityPlease consult thesecurity guidefor our responsible security vulnerability disclosure processLicenseCopyright (c) 2023 Oracle and/or its affiliates.Released under the Universal Permissive License v1.0 as shown athttps://oss.oracle.com/licenses/upl/.