Skip to main content

The Coherence Python Client allows Python applications to act as cache clients to a Coherence Cluster using Google's gRPC framework as the network transport.

Project description

Python Client for Oracle Coherence

CI/CD Quality Gate Status License

The Coherence Python Client allows Python applications to act as cache clients to an Oracle Coherence cluster using gRPC as the network transport.

Features

  • Familiar 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_value
  • Cluster-side querying, aggregation and filtering of map entries
  • Cluster-side manipulation of map entries using EntryProcessors
  • Registration of listeners to be notified of:
    • mutations such as insert, update and delete on Maps
    • map lifecycle events such as truncated, released or destroyed
    • session lifecycle events such as connected, disconnected, reconnected and closed
  • Support 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's

Requirements

  • Coherence CE 22.06.11+ or Coherence 14.1.1.2206.11+, 14.1.2.0+ Commercial edition with a configured gRPCProxy.
  • Usage of module coherence.ai requires Coherence CE 24.09.2+
  • Python 3.9.x or later

Starting a Coherence Cluster

Before 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.

docker run -d -p 1408:1408 ghcr.io/oracle/coherence-ce:25.03.1

Installation

python3 -m pip install coherence-client

Documentation

https://oracle.github.io/coherence-py-client/

Examples

The following example connects to a Coherence cluster running gRPC Proxy on default port of 1408, creates a new NamedCache with key str and value of a str|int and issues put(), get(), size() and remove operations.

from coherence import NamedCache, Session
import asyncio
from typing import Union


async def run_test():

    # create a new Session to the Coherence server
    session: Session = await Session.create()

    # create a new NamedCache with key of string|int and value of string|int
    cache: NamedCache[str, Union[str,int]] = await session.get_cache("test")

    # put a new key/value
    k: str = "one"
    v: str = "only-one"
    await cache.put(k, v)

    # get the value for a key in the cache
    r = await cache.get(k)

    # print the value got for a key in the cache
    print("The value of key \"one\" is " + r)

    k1: str = "two"
    v1: int = 2
    await cache.put(k1, v1)
    r = await cache.get(k1)
    print("The value of key \"two\" is " + str(r))

    # print the size of the cache
    print("Size of the cache test is " + str(await cache.size()))

    # remove an entry from the cache
    await cache.remove(k1)


# run the test
asyncio.run(run_test())

Help

We have a public Slack channel where you can get in touch with us to ask questions about using the Coherence Python Client 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, please visit 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 #coherence and say, "hello!"

If you would like to raise an issue please see here.

Contributing

This project welcomes contributions from the community. Before submitting a pull request, please review our contribution guide

Security

Please consult the security guide for our responsible security vulnerability disclosure process

License

Copyright (c) 2023, 2025, Oracle and/or its affiliates.

Released under the Universal Permissive License v1.0 as shown at https://oss.oracle.com/licenses/upl/.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

coherence_client-2.0.4.tar.gz (88.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

coherence_client-2.0.4-py3-none-any.whl (98.6 kB view details)

Uploaded Python 3

File details

Details for the file coherence_client-2.0.4.tar.gz.

File metadata

  • Download URL: coherence_client-2.0.4.tar.gz
  • Upload date:
  • Size: 88.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.23

File hashes

Hashes for coherence_client-2.0.4.tar.gz
Algorithm Hash digest
SHA256 734a5876e50c1f9628ca2d8f3ca58a541cdf0fa53151e5946691aa75eb71bde8
MD5 3cf2db9a806d1f43a15b6e9ca73daf83
BLAKE2b-256 2b2d194cb7f16f12093ae689ff742eeec3b75bc28e1e9c09ac562287c8feb4f0

See more details on using hashes here.

File details

Details for the file coherence_client-2.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for coherence_client-2.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 d11c2a4b4d86e4960aeb0daf3b9438ea60631738720aee2d4750a6f678d20b1a
MD5 c706e0f16fd7eef6e76240f690fc5ffc
BLAKE2b-256 08de06d2882b3494119d7381db2651467ee3aef1d28bc32312e83e5b7907d5c7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page