Skip to content

Adding ttl with put doesnt save entry #93

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
vinod4dev opened this issue May 1, 2016 · 1 comment
Closed

Adding ttl with put doesnt save entry #93

vinod4dev opened this issue May 1, 2016 · 1 comment

Comments

@vinod4dev
Copy link

In the example here example , if I add a entry using map.put("1", person,1000) (ttl of 1000 seconds ) ,it doesnt seem to work .And always returns an empty value even before ttl.

@mustafaiman
Copy link
Contributor

Hello @vinod4dev . Time unit of TTL is actually milliseconds, not seconds. In your case, TTL is only 1 second. Probably you try to access the value after it is evicted. There is a mistake in our documentation. I tried below code(ttl is 10 seconds) just to be sure and it worked as expected:

var HazelcastClient = require('hazelcast-client').Client;
var Config = require('hazelcast-client').Config;

var config = new Config.ClientConfig();
config.networkConfig.addresses = [{host: '127.0.0.1', port: '5701'}];

var map = {};

HazelcastClient
    .newHazelcastClient(config)
    .then(function (hazelcastClient) {
        map = hazelcastClient.getMap("persons");
        insertPerson(map);
        readPerson(map);
    });

var printValue = function (text, value) {
    console.log(text + JSON.stringify(value));
};

var insertPerson = function (map) {
    var person = {
        firstName: "Joe",
        lastName: "Doe",
        age: 42
    };
    map.put(1, person, 10000).then(function (previousValue) {
        printValue("Previous value: ", previousValue);
    });
};

var readPerson = function (map) {
    map.get(1).then(function (value) {
        printValue("Value for key=1: ", value);
    })
};

I opened a new issue for documentation fix: #94
I am closing this issue. Feel free to reopen it if you still have problems.
Thank you for trying hazelcast node.js client.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants