|
10 | 10 | map_is_locked_codec, map_key_set_codec, map_key_set_with_predicate_codec, map_load_all_codec, \ |
11 | 11 | map_load_given_keys_codec, map_lock_codec, map_put_codec, map_put_all_codec, map_put_if_absent_codec, \ |
12 | 12 | map_put_transient_codec, map_size_codec, map_remove_codec, map_remove_if_same_codec, \ |
13 | | - map_remove_entry_listener_codec, map_replace_codec, map_replace_if_same_codec, map_set_codec, map_try_lock_codec, \ |
14 | | - map_try_put_codec, map_try_remove_codec, map_unlock_codec, map_values_codec, map_values_with_predicate_codec, \ |
15 | | - map_add_interceptor_codec, map_execute_on_all_keys_codec, map_execute_on_key_codec, map_execute_on_keys_codec, \ |
16 | | - map_execute_with_predicate_codec, map_add_near_cache_entry_listener_codec |
| 13 | + map_remove_entry_listener_codec, map_replace_codec, map_replace_if_same_codec, map_set_codec, map_set_ttl_codec, \ |
| 14 | + map_try_lock_codec, map_try_put_codec, map_try_remove_codec, map_unlock_codec, map_values_codec, \ |
| 15 | + map_values_with_predicate_codec, map_add_interceptor_codec, map_execute_on_all_keys_codec, map_execute_on_key_codec, \ |
| 16 | + map_execute_on_keys_codec, map_execute_with_predicate_codec, map_add_near_cache_entry_listener_codec |
17 | 17 | from hazelcast.proxy.base import Proxy, EntryEvent, EntryEventType, get_entry_listener_flags, MAX_SIZE |
18 | 18 | from hazelcast.util import check_not_none, thread_id, to_millis |
19 | 19 | from hazelcast import six |
@@ -725,6 +725,22 @@ def set(self, key, value, ttl=-1): |
725 | 725 | value_data = self._to_data(value) |
726 | 726 | return self._set_internal(key_data, value_data, ttl) |
727 | 727 |
|
| 728 | + def set_ttl(self, key, ttl): |
| 729 | + """ |
| 730 | + Updates the TTL (time to live) value of the entry specified by the given key with a new TTL value. New TTL |
| 731 | + value is valid starting from the time this operation is invoked, not since the time the entry was created. |
| 732 | + If the entry does not exist or is already expired, this call has no effect. |
| 733 | +
|
| 734 | + :param key: (object), the key of the map entry. |
| 735 | + :param ttl: (int), maximum time for this entry to stay in the map (0 means infinite, |
| 736 | + negative means map config default) |
| 737 | + """ |
| 738 | + check_not_none(key, "key can't be None") |
| 739 | + check_not_none(ttl, "ttl can't be None") |
| 740 | + key_data = self._to_data(key) |
| 741 | + return self._encode_invoke_on_key(map_set_ttl_codec, key_data, key=key_data, ttl=to_millis(ttl)) |
| 742 | + |
| 743 | + |
728 | 744 | def size(self): |
729 | 745 | """ |
730 | 746 | Returns the number of entries in this map. |
|
0 commit comments