Skip to content

Commit eeef976

Browse files
isapegoivandasch
andauthored
GG-33821 [IGNITE-14595] Implement ExpiryPolicy support (#45)
(cherry picked from commit 9f72781) Co-authored-by: Ivan Daschinsky <[email protected]>
1 parent 79d8e9a commit eeef976

38 files changed

+1309
-649
lines changed

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@ GridGain Community Edition thin (binary protocol) client, written in Python 3.
33

44
## Prerequisites
55

6-
- Python 3.4 or above (3.6 is tested),
6+
- Python 3.6 or above (3.6, 3.7, 3.8 and 3.9 are tested),
77
- Access to GridGain node, local or remote. The current thin client
8-
version was tested on GridGain CE 8.7 (binary client protocol versions
9-
1.2.0 to 1.4.0).
8+
version was tested on GridGain CE 8.7 and 8.8 (binary client protocol 1.7.0).
109

1110
## Installation
1211

docs/async_examples.rst

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,39 @@ that yields the resulting rows.
4747

4848
.. literalinclude:: ../examples/async_key_value.py
4949
:language: python
50-
:dedent: 4
50+
:dedent: 8
5151
:lines: 39-50
5252

53+
ExpiryPolicy
54+
============
55+
File: `expiry_policy.py`_.
5356

54-
File: `async_sql.py`_.
57+
You can enable expiry policy (TTL) by two approaches.
58+
59+
Firstly, expiry policy can be set for entire cache by setting :py:attr:`~pygridgain.datatypes.prop_codes.PROP_EXPIRY_POLICY`
60+
in cache settings dictionary on creation.
61+
62+
.. literalinclude:: ../examples/expiry_policy.py
63+
:language: python
64+
:dedent: 12
65+
:lines: 72-75
66+
67+
.. literalinclude:: ../examples/expiry_policy.py
68+
:language: python
69+
:dedent: 12
70+
:lines: 81-89
71+
72+
Secondly, expiry policy can be set for all cache operations, which are done under decorator. To create it use
73+
:py:meth:`~pygridgain.cache.BaseCache.with_expire_policy`
74+
75+
.. literalinclude:: ../examples/expiry_policy.py
76+
:language: python
77+
:dedent: 12
78+
:lines: 96-105
5579

5680
SQL
5781
---
82+
File: `async_sql.py`_.
5883

5984
First let us establish a connection.
6085

@@ -145,6 +170,6 @@ Finally, delete the tables used in this example with the following queries:
145170

146171

147172

148-
173+
.. _expiry_policy.py: https://github.com/apache/ignite-python-thin-client/blob/master/examples/expiry_policy.py
149174
.. _async_key_value.py: https://github.com/apache/ignite-python-thin-client/blob/master/examples/async_key_value.py
150175
.. _async_sql.py: https://github.com/apache/ignite-python-thin-client/blob/master/examples/async_sql.py

docs/datatypes/cache_props.rst

Lines changed: 76 additions & 68 deletions
Large diffs are not rendered by default.

docs/examples.rst

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,33 @@ As a rule of thumb:
8484
Refer the :ref:`data_types` section for the full list
8585
of parser/constructor classes you can use as type hints.
8686

87+
ExpiryPolicy
88+
============
89+
File: `expiry_policy.py`_.
90+
91+
You can enable expiry policy (TTL) by two approaches.
92+
93+
Firstly, expiry policy can be set for entire cache by setting :py:attr:`~pygridgain.datatypes.prop_codes.PROP_EXPIRY_POLICY`
94+
in cache settings dictionary on creation.
95+
96+
.. literalinclude:: ../examples/expiry_policy.py
97+
:language: python
98+
:dedent: 12
99+
:lines: 31-34
100+
101+
.. literalinclude:: ../examples/expiry_policy.py
102+
:language: python
103+
:dedent: 12
104+
:lines: 40-46
105+
106+
Secondly, expiry policy can be set for all cache operations, which are done under decorator. To create it use
107+
:py:meth:`~pygridgain.cache.BaseCache.with_expire_policy`
108+
109+
.. literalinclude:: ../examples/expiry_policy.py
110+
:language: python
111+
:dedent: 12
112+
:lines: 53-60
113+
87114
Scan
88115
====
89116
File: `scans.py`_.
@@ -557,13 +584,13 @@ Gather 3 GridGain nodes on `localhost` into one cluster and run:
557584

558585
.. literalinclude:: ../examples/failover.py
559586
:language: python
560-
:lines: 16-53
587+
:lines: 16-52
561588

562589
Then try shutting down and restarting nodes, and see what happens.
563590

564591
.. literalinclude:: ../examples/failover.py
565592
:language: python
566-
:lines: 55-67
593+
:lines: 54-66
567594

568595
Client reconnection do not require an explicit user action, like calling
569596
a special method or resetting a parameter.
@@ -682,6 +709,7 @@ with the following message:
682709
.. _type_hints.py: https://github.com/gridgain/python-thin-client/tree/master/examples/type_hints.py
683710
.. _failover.py: https://github.com/gridgain/python-thin-client/tree/master/examples/failover.py
684711
.. _scans.py: https://github.com/gridgain/python-thin-client/tree/master/examples/scans.py
712+
.. _expiry_policy.py: https://github.com/apache/ignite-python-thin-client/blob/master/examples/expiry_policy.py
685713
.. _sql.py: https://github.com/gridgain/python-thin-client/tree/master/examples/sql.py
686714
.. _async_sql.py: https://github.com/apache/ignite-python-thin-client/blob/master/examples/async_sql.py
687715
.. _binary_basics.py: https://github.com/gridgain/python-thin-client/tree/master/examples/binary_basics.py
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
.. Copyright 2021 GridGain Systems, Inc. and Contributors.
2+
3+
.. Licensed under the GridGain Community Edition License (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
.. https://www.gridgain.com/products/software/community-edition/gridgain-community-edition-license
8+
9+
.. Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.
14+
15+
pygridgain.aio_cluster module
16+
===========================
17+
18+
.. automodule:: pygridgain.aio_cluster
19+
:members:
20+
:undoc-members:
21+
:show-inheritance:

docs/source/pyignite.cluster.rst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
.. Copyright 2021 GridGain Systems, Inc. and Contributors.
2+
3+
.. Licensed under the GridGain Community Edition License (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
.. https://www.gridgain.com/products/software/community-edition/gridgain-community-edition-license
8+
9+
.. Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.
14+
15+
pygridgain.cluster module
16+
=======================
17+
18+
.. automodule:: pygridgain.cluster
19+
:members:
20+
:undoc-members:
21+
:show-inheritance:
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
.. Copyright 2021 GridGain Systems, Inc. and Contributors.
2+
3+
.. Licensed under the GridGain Community Edition License (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
.. https://www.gridgain.com/products/software/community-edition/gridgain-community-edition-license
8+
9+
.. Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.
14+
15+
pygridgain.datatypes.cluster_state module
16+
=======================================
17+
18+
.. automodule:: pygridgain.datatypes.cluster_state
19+
:members:
20+
:show-inheritance:
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
.. Copyright 2021 GridGain Systems, Inc. and Contributors.
2+
3+
.. Licensed under the GridGain Community Edition License (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
.. https://www.gridgain.com/products/software/community-edition/gridgain-community-edition-license
8+
9+
.. Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.
14+
15+
pygridgain.datatypes.expiry_policy module
16+
=======================================
17+
18+
.. automodule:: pygridgain.datatypes.expiry_policy
19+
:members:
20+
:show-inheritance:

docs/source/pyignite.datatypes.rst

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
.. Copyright 2021 GridGain Systems, Inc. and Contributors.
2+
3+
.. Licensed under the GridGain Community Edition License (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
.. https://www.gridgain.com/products/software/community-edition/gridgain-community-edition-license
8+
9+
.. Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.
14+
15+
pygridgain.datatypes package
16+
==========================
17+
18+
.. automodule:: pygridgain.datatypes
19+
:members:
20+
:undoc-members:
21+
:show-inheritance:
22+
23+
Submodules
24+
----------
25+
26+
.. toctree::
27+
28+
pygridgain.datatypes.base
29+
pygridgain.datatypes.binary
30+
pygridgain.datatypes.cache_config
31+
pygridgain.datatypes.cache_properties
32+
pygridgain.datatypes.complex
33+
pygridgain.datatypes.cluster_state
34+
pygridgain.datatypes.expiry_policy
35+
pygridgain.datatypes.internal
36+
pygridgain.datatypes.key_value
37+
pygridgain.datatypes.null_object
38+
pygridgain.datatypes.primitive
39+
pygridgain.datatypes.primitive_arrays
40+
pygridgain.datatypes.primitive_objects
41+
pygridgain.datatypes.sql
42+
pygridgain.datatypes.standard

docs/source/pyignite.rst

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
.. Copyright 2021 GridGain Systems, Inc. and Contributors.
2+
3+
.. Licensed under the GridGain Community Edition License (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
.. https://www.gridgain.com/products/software/community-edition/gridgain-community-edition-license
8+
9+
.. Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.
14+
15+
pygridgain package
16+
================
17+
18+
.. automodule:: pygridgain
19+
:members:
20+
:undoc-members:
21+
:show-inheritance:
22+
23+
Subpackages
24+
-----------
25+
26+
.. toctree::
27+
28+
pygridgain.datatypes
29+
pygridgain.connection
30+
31+
Submodules
32+
----------
33+
34+
.. toctree::
35+
36+
pygridgain.binary
37+
pygridgain.cache
38+
pygridgain.aio_cache
39+
pygridgain.client
40+
pygridgain.aio_client
41+
pygridgain.cluster
42+
pygridgain.aio_cluster
43+
pygridgain.cursors
44+
pygridgain.exceptions
45+

0 commit comments

Comments
 (0)