|
| 1 | +/* |
| 2 | + * Copyright (c) 2008-2022, Hazelcast, Inc. All Rights Reserved. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * 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 | +'use strict'; |
| 17 | + |
| 18 | +const { Client, Predicates } = require('hazelcast-client'); |
| 19 | + |
| 20 | +(async () => { |
| 21 | + const client = await Client.newHazelcastClient(); |
| 22 | + const map = await client.getMap('my-distributed-map'); |
| 23 | + |
| 24 | + for (let i = 0; i < 10 ; i++) { |
| 25 | + await map.put('key' + i, i); |
| 26 | + } |
| 27 | + console.log('Map size before removing:', await map.size()); |
| 28 | + |
| 29 | + const predicate = Predicates.between('this', 3, 7); |
| 30 | + await map.removeAll(predicate); |
| 31 | + |
| 32 | + console.log('Map size after removing:', await map.size()); |
| 33 | + |
| 34 | + await client.shutdown(); |
| 35 | +})().catch(err => { |
| 36 | + console.error('Error occurred:', err); |
| 37 | + process.exit(1); |
| 38 | +}); |
| 39 | + |
0 commit comments