Skip to content

Commit 9f72781

Browse files
committed
IGNITE-14595 Implement ExpiryPolicy support - Fixes #35.
1 parent 8b1e61c commit 9f72781

38 files changed

+1235
-659
lines changed

README.md

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

44
## Prerequisites
55

6-
- Python 3.4 or above (3.6, 3.7 and 3.8 are tested),
6+
- Python 3.6 or above (3.6, 3.7, 3.8 and 3.9 are tested),
77
- Access to Apache Ignite node, local or remote. The current thin client
8-
version was tested on Apache Ignite 2.7.0 (binary client protocol 1.2.0).
8+
version was tested on Apache Ignite 2.10 (binary client protocol 1.7.0).
99

1010
## Installation
1111

docs/async_examples.rst

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

4949
.. literalinclude:: ../examples/async_key_value.py
5050
:language: python
51-
:dedent: 4
51+
:dedent: 8
5252
:lines: 39-50
5353

54+
ExpiryPolicy
55+
============
56+
File: `expiry_policy.py`_.
5457

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

5781
SQL
5882
---
83+
File: `async_sql.py`_.
5984

6085
First let us establish a connection.
6186

@@ -146,6 +171,6 @@ Finally, delete the tables used in this example with the following queries:
146171

147172

148173

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

docs/datatypes/cache_props.rst

Lines changed: 80 additions & 72 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
@@ -85,6 +85,33 @@ As a rule of thumb:
8585
Refer the :ref:`data_types` section for the full list
8686
of parser/constructor classes you can use as type hints.
8787

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

559586
.. literalinclude:: ../examples/failover.py
560587
:language: python
561-
:lines: 16-53
588+
:lines: 16-52
562589

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

565592
.. literalinclude:: ../examples/failover.py
566593
:language: python
567-
:lines: 55-67
594+
:lines: 54-66
568595

569596
Client reconnection do not require an explicit user action, like calling
570597
a special method or resetting a parameter.
@@ -683,6 +710,7 @@ with the following message:
683710
.. _type_hints.py: https://github.com/apache/ignite-python-thin-client/blob/master/examples/type_hints.py
684711
.. _failover.py: https://github.com/apache/ignite-python-thin-client/blob/master/examples/failover.py
685712
.. _scans.py: https://github.com/apache/ignite-python-thin-client/blob/master/examples/scans.py
713+
.. _expiry_policy.py: https://github.com/apache/ignite-python-thin-client/blob/master/examples/expiry_policy.py
686714
.. _sql.py: https://github.com/apache/ignite-python-thin-client/blob/master/examples/sql.py
687715
.. _async_sql.py: https://github.com/apache/ignite-python-thin-client/blob/master/examples/async_sql.py
688716
.. _binary_basics.py: https://github.com/apache/ignite-python-thin-client/blob/master/examples/binary_basics.py
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
.. Licensed to the Apache Software Foundation (ASF) under one or more
2+
contributor license agreements. See the NOTICE file distributed with
3+
this work for additional information regarding copyright ownership.
4+
The ASF licenses this file to You under the Apache License, Version 2.0
5+
(the "License"); you may not use this file except in compliance with
6+
the License. You may obtain a copy of the License at
7+
8+
.. http://www.apache.org/licenses/LICENSE-2.0
9+
10+
.. Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
16+
pyignite.aio_cluster module
17+
===========================
18+
19+
.. automodule:: pyignite.aio_cluster
20+
:members:
21+
:undoc-members:
22+
:show-inheritance:

docs/source/pyignite.cluster.rst

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
.. Licensed to the Apache Software Foundation (ASF) under one or more
2+
contributor license agreements. See the NOTICE file distributed with
3+
this work for additional information regarding copyright ownership.
4+
The ASF licenses this file to You under the Apache License, Version 2.0
5+
(the "License"); you may not use this file except in compliance with
6+
the License. You may obtain a copy of the License at
7+
8+
.. http://www.apache.org/licenses/LICENSE-2.0
9+
10+
.. Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
16+
pyignite.cluster module
17+
=======================
18+
19+
.. automodule:: pyignite.cluster
20+
:members:
21+
:undoc-members:
22+
:show-inheritance:
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
.. Licensed to the Apache Software Foundation (ASF) under one or more
2+
contributor license agreements. See the NOTICE file distributed with
3+
this work for additional information regarding copyright ownership.
4+
The ASF licenses this file to You under the Apache License, Version 2.0
5+
(the "License"); you may not use this file except in compliance with
6+
the License. You may obtain a copy of the License at
7+
8+
.. http://www.apache.org/licenses/LICENSE-2.0
9+
10+
.. Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
16+
pyignite.datatypes.cluster_state module
17+
=======================================
18+
19+
.. automodule:: pyignite.datatypes.cluster_state
20+
:members:
21+
:show-inheritance:
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
.. Licensed to the Apache Software Foundation (ASF) under one or more
2+
contributor license agreements. See the NOTICE file distributed with
3+
this work for additional information regarding copyright ownership.
4+
The ASF licenses this file to You under the Apache License, Version 2.0
5+
(the "License"); you may not use this file except in compliance with
6+
the License. You may obtain a copy of the License at
7+
8+
.. http://www.apache.org/licenses/LICENSE-2.0
9+
10+
.. Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
16+
pyignite.datatypes.expiry_policy module
17+
=======================================
18+
19+
.. automodule:: pyignite.datatypes.expiry_policy
20+
:members:
21+
:show-inheritance:

docs/source/pyignite.datatypes.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ Submodules
3131
pyignite.datatypes.cache_config
3232
pyignite.datatypes.cache_properties
3333
pyignite.datatypes.complex
34+
pyignite.datatypes.cluster_state
35+
pyignite.datatypes.expiry_policy
3436
pyignite.datatypes.internal
3537
pyignite.datatypes.key_value
3638
pyignite.datatypes.null_object
@@ -39,4 +41,3 @@ Submodules
3941
pyignite.datatypes.primitive_objects
4042
pyignite.datatypes.sql
4143
pyignite.datatypes.standard
42-

docs/source/pyignite.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ Submodules
3939
pyignite.aio_cache
4040
pyignite.client
4141
pyignite.aio_client
42-
pyignite.constants
42+
pyignite.cluster
43+
pyignite.aio_cluster
4344
pyignite.cursors
4445
pyignite.exceptions
4546

0 commit comments

Comments
 (0)