You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by scriptnull <vi...@gmail.com> on 2020/05/18 14:09:31 UTC

Can we set TTL (expiry time) of a key-value from thin client?

I would like to break down this question into two questions.

1. Can we have key-values with different expire times in the same cache? (I
think the answer for this is yes, because the redis layer in ignite allows
for this)

2. I am trying to build a ruby thin client for Apache Ignite and got a basic
prototype in place. But I couldn't find an operation in binary protocol
documentation that will enable us to set TTL for a key-value pair.  So, any
idea on how to set TTL via the binary protocol?



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Re: Can we set TTL (expiry time) of a key-value from thin client?

Posted by Pavel Tupitsyn <pt...@apache.org>.
> you could specify the expiration policy on the actual "Put" call itself
That is true on the protocol level.
User-facing API has WithExpiryPolicy so we don't have to add an additional
overload for every cache operation.

On Tue, May 19, 2020 at 5:00 PM Marty Jones <ma...@gmail.com> wrote:

> Pavel,
>
> My bad, I misunderstood the question.  The code I am using works fine.  I
> thought the previous discussion was stating that you could specify the
> expiration policy on the actual "Put" call itself.
>
> On Tue, May 19, 2020 at 8:53 AM Pavel Tupitsyn <pt...@apache.org>
> wrote:
>
>> Marty, can you please elaborate?
>> We are talking about protocol-level details in this thread.
>> Your code for .NET Thin Client seems to be fine, does it work as expected?
>>
>> On Tue, May 19, 2020 at 4:39 PM Marty Jones <ma...@gmail.com>
>> wrote:
>>
>>> I am not seeing that option in the ASP.NET thin client.   This is how I
>>> accomplished setting an expiration policy:
>>>
>>> ICacheClient<string, CacheItemEntry> cache =
>>> igniteClient.GetCache<string, CacheItemEntry>("testCache");
>>>
>>> cache.WithExpiryPolicy(new ExpiryPolicy(TimeSpan.FromSeconds(15), null,
>>> null))
>>>          .Put("test1", new CacheItemEntry() { Entry = "test" });
>>>
>>> On Tue, May 19, 2020 at 8:17 AM Pavel Tupitsyn <pt...@apache.org>
>>> wrote:
>>>
>>>> > if there is support for setting expire times for multiple key-values
>>>> > while doing a OP_CACHE_PUT_ALL
>>>>
>>>> The answer is yes. All key-val operations support expiration, namely:
>>>> OP_CACHE_PUT
>>>> OP_CACHE_PUT_IF_ABSENT
>>>> OP_CACHE_PUT_ALL
>>>> OP_CACHE_GET_AND_PUT
>>>> OP_CACHE_GET_AND_REPLACE
>>>> OP_CACHE_GET_AND_PUT_IF_ABSENT
>>>> OP_CACHE_REPLACE
>>>> OP_CACHE_REPLACE_IF_EQUALS
>>>>
>>>>
>>>>
>>>> On Tue, May 19, 2020 at 4:11 PM scriptnull <vi...@gmail.com>
>>>> wrote:
>>>>
>>>>> Awesome, that's exactly the information that I needed. So we will have
>>>>> to set
>>>>> the flag byte while doing OP_CACHE_PUT.
>>>>>
>>>>> Do you know by any chance if there is support for setting expire times
>>>>> for
>>>>> multiple key-values while doing a OP_CACHE_PUT_ALL (opcode: 1004)
>>>>> operation?
>>>>> I am guessing the answer is no.
>>>>>
>>>>> Regards,
>>>>> Vishnu Bharathi P
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>>>>>
>>>>

Re: Can we set TTL (expiry time) of a key-value from thin client?

Posted by Marty Jones <ma...@gmail.com>.
Pavel,

My bad, I misunderstood the question.  The code I am using works fine.  I
thought the previous discussion was stating that you could specify the
expiration policy on the actual "Put" call itself.

On Tue, May 19, 2020 at 8:53 AM Pavel Tupitsyn <pt...@apache.org> wrote:

> Marty, can you please elaborate?
> We are talking about protocol-level details in this thread.
> Your code for .NET Thin Client seems to be fine, does it work as expected?
>
> On Tue, May 19, 2020 at 4:39 PM Marty Jones <ma...@gmail.com> wrote:
>
>> I am not seeing that option in the ASP.NET thin client.   This is how I
>> accomplished setting an expiration policy:
>>
>> ICacheClient<string, CacheItemEntry> cache =
>> igniteClient.GetCache<string, CacheItemEntry>("testCache");
>>
>> cache.WithExpiryPolicy(new ExpiryPolicy(TimeSpan.FromSeconds(15), null,
>> null))
>>          .Put("test1", new CacheItemEntry() { Entry = "test" });
>>
>> On Tue, May 19, 2020 at 8:17 AM Pavel Tupitsyn <pt...@apache.org>
>> wrote:
>>
>>> > if there is support for setting expire times for multiple key-values
>>> > while doing a OP_CACHE_PUT_ALL
>>>
>>> The answer is yes. All key-val operations support expiration, namely:
>>> OP_CACHE_PUT
>>> OP_CACHE_PUT_IF_ABSENT
>>> OP_CACHE_PUT_ALL
>>> OP_CACHE_GET_AND_PUT
>>> OP_CACHE_GET_AND_REPLACE
>>> OP_CACHE_GET_AND_PUT_IF_ABSENT
>>> OP_CACHE_REPLACE
>>> OP_CACHE_REPLACE_IF_EQUALS
>>>
>>>
>>>
>>> On Tue, May 19, 2020 at 4:11 PM scriptnull <vi...@gmail.com>
>>> wrote:
>>>
>>>> Awesome, that's exactly the information that I needed. So we will have
>>>> to set
>>>> the flag byte while doing OP_CACHE_PUT.
>>>>
>>>> Do you know by any chance if there is support for setting expire times
>>>> for
>>>> multiple key-values while doing a OP_CACHE_PUT_ALL (opcode: 1004)
>>>> operation?
>>>> I am guessing the answer is no.
>>>>
>>>> Regards,
>>>> Vishnu Bharathi P
>>>>
>>>>
>>>>
>>>> --
>>>> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>>>>
>>>

Re: Can we set TTL (expiry time) of a key-value from thin client?

Posted by Pavel Tupitsyn <pt...@apache.org>.
Marty, can you please elaborate?
We are talking about protocol-level details in this thread.
Your code for .NET Thin Client seems to be fine, does it work as expected?

On Tue, May 19, 2020 at 4:39 PM Marty Jones <ma...@gmail.com> wrote:

> I am not seeing that option in the ASP.NET thin client.   This is how I
> accomplished setting an expiration policy:
>
> ICacheClient<string, CacheItemEntry> cache = igniteClient.GetCache<string,
> CacheItemEntry>("testCache");
>
> cache.WithExpiryPolicy(new ExpiryPolicy(TimeSpan.FromSeconds(15), null,
> null))
>          .Put("test1", new CacheItemEntry() { Entry = "test" });
>
> On Tue, May 19, 2020 at 8:17 AM Pavel Tupitsyn <pt...@apache.org>
> wrote:
>
>> > if there is support for setting expire times for multiple key-values
>> > while doing a OP_CACHE_PUT_ALL
>>
>> The answer is yes. All key-val operations support expiration, namely:
>> OP_CACHE_PUT
>> OP_CACHE_PUT_IF_ABSENT
>> OP_CACHE_PUT_ALL
>> OP_CACHE_GET_AND_PUT
>> OP_CACHE_GET_AND_REPLACE
>> OP_CACHE_GET_AND_PUT_IF_ABSENT
>> OP_CACHE_REPLACE
>> OP_CACHE_REPLACE_IF_EQUALS
>>
>>
>>
>> On Tue, May 19, 2020 at 4:11 PM scriptnull <vi...@gmail.com>
>> wrote:
>>
>>> Awesome, that's exactly the information that I needed. So we will have
>>> to set
>>> the flag byte while doing OP_CACHE_PUT.
>>>
>>> Do you know by any chance if there is support for setting expire times
>>> for
>>> multiple key-values while doing a OP_CACHE_PUT_ALL (opcode: 1004)
>>> operation?
>>> I am guessing the answer is no.
>>>
>>> Regards,
>>> Vishnu Bharathi P
>>>
>>>
>>>
>>> --
>>> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>>>
>>

Re: Can we set TTL (expiry time) of a key-value from thin client?

Posted by Marty Jones <ma...@gmail.com>.
I am not seeing that option in the ASP.NET thin client.   This is how I
accomplished setting an expiration policy:

ICacheClient<string, CacheItemEntry> cache = igniteClient.GetCache<string,
CacheItemEntry>("testCache");

cache.WithExpiryPolicy(new ExpiryPolicy(TimeSpan.FromSeconds(15), null,
null))
         .Put("test1", new CacheItemEntry() { Entry = "test" });

On Tue, May 19, 2020 at 8:17 AM Pavel Tupitsyn <pt...@apache.org> wrote:

> > if there is support for setting expire times for multiple key-values
> > while doing a OP_CACHE_PUT_ALL
>
> The answer is yes. All key-val operations support expiration, namely:
> OP_CACHE_PUT
> OP_CACHE_PUT_IF_ABSENT
> OP_CACHE_PUT_ALL
> OP_CACHE_GET_AND_PUT
> OP_CACHE_GET_AND_REPLACE
> OP_CACHE_GET_AND_PUT_IF_ABSENT
> OP_CACHE_REPLACE
> OP_CACHE_REPLACE_IF_EQUALS
>
>
>
> On Tue, May 19, 2020 at 4:11 PM scriptnull <vi...@gmail.com>
> wrote:
>
>> Awesome, that's exactly the information that I needed. So we will have to
>> set
>> the flag byte while doing OP_CACHE_PUT.
>>
>> Do you know by any chance if there is support for setting expire times for
>> multiple key-values while doing a OP_CACHE_PUT_ALL (opcode: 1004)
>> operation?
>> I am guessing the answer is no.
>>
>> Regards,
>> Vishnu Bharathi P
>>
>>
>>
>> --
>> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>>
>

Re: Can we set TTL (expiry time) of a key-value from thin client?

Posted by Pavel Tupitsyn <pt...@apache.org>.
> if there is support for setting expire times for multiple key-values
> while doing a OP_CACHE_PUT_ALL

The answer is yes. All key-val operations support expiration, namely:
OP_CACHE_PUT
OP_CACHE_PUT_IF_ABSENT
OP_CACHE_PUT_ALL
OP_CACHE_GET_AND_PUT
OP_CACHE_GET_AND_REPLACE
OP_CACHE_GET_AND_PUT_IF_ABSENT
OP_CACHE_REPLACE
OP_CACHE_REPLACE_IF_EQUALS



On Tue, May 19, 2020 at 4:11 PM scriptnull <vi...@gmail.com>
wrote:

> Awesome, that's exactly the information that I needed. So we will have to
> set
> the flag byte while doing OP_CACHE_PUT.
>
> Do you know by any chance if there is support for setting expire times for
> multiple key-values while doing a OP_CACHE_PUT_ALL (opcode: 1004)
> operation?
> I am guessing the answer is no.
>
> Regards,
> Vishnu Bharathi P
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>

Re: Can we set TTL (expiry time) of a key-value from thin client?

Posted by scriptnull <vi...@gmail.com>.
Awesome, that's exactly the information that I needed. So we will have to set
the flag byte while doing OP_CACHE_PUT.

Do you know by any chance if there is support for setting expire times for
multiple key-values while doing a OP_CACHE_PUT_ALL (opcode: 1004) operation?
I am guessing the answer is no.

Regards,
Vishnu Bharathi P



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Re: Can we set TTL (expiry time) of a key-value from thin client?

Posted by Pavel Tupitsyn <pt...@apache.org>.
Hi,

Yes, every cache request has Flags byte right after cacheId.
There is FLAG_WITH_EXPIRY_POLICY = 0x04.
When this flag is set, server expects 3 long values (3x8 bytes) after flags
byte,
representing TTL for Create, Update, and Access, in milliseconds

For example, if we want to store a cache entry that should expire in 3
seconds,
we execute OP_CACHE_PUT (1001) operation, set FLAG_WITH_EXPIRY_POLICY,
and pass 3000, 0, 0 as TTL values.

Let me know if you need more details.

Thanks,
Pavel

On Tue, May 19, 2020 at 3:27 PM scriptnull <vi...@gmail.com>
wrote:

> Hi,
>
> I am referring to any of the thin clients
> (java/.net/c++/node.js/python/php)
> documented at https://apacheignite.readme.io/docs/thin-clients
>
> I wonder if any of those thin clients have an API to set TTL for a
> key-value
> in a cache. If so I can reverse engineer the implementation of it and
> implement it in the ruby thin client implementation that I am currently
> working on.
>
> More specifically, I am interested in knowing if there is an operation in
> binary protocol like OP_CACHE_UPDATE_TTL
>
> If there is such an operation, I could call it via a ruby thin client
> implementation that I am working on currently.
>
> Regards,
> Vishnu Bharathi P
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>

Re: Can we set TTL (expiry time) of a key-value from thin client?

Posted by scriptnull <vi...@gmail.com>.
Hi,

I am referring to any of the thin clients (java/.net/c++/node.js/python/php)
documented at https://apacheignite.readme.io/docs/thin-clients

I wonder if any of those thin clients have an API to set TTL for a key-value
in a cache. If so I can reverse engineer the implementation of it and
implement it in the ruby thin client implementation that I am currently
working on.

More specifically, I am interested in knowing if there is an operation in
binary protocol like OP_CACHE_UPDATE_TTL

If there is such an operation, I could call it via a ruby thin client
implementation that I am working on currently.

Regards,
Vishnu Bharathi P



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Re: Can we set TTL (expiry time) of a key-value from thin client?

Posted by Igor Sapego <is...@apache.org>.
Which thin client are you referring to?

Best Regards,
Igor


On Mon, May 18, 2020 at 5:09 PM scriptnull <vi...@gmail.com>
wrote:

> I would like to break down this question into two questions.
>
> 1. Can we have key-values with different expire times in the same cache? (I
> think the answer for this is yes, because the redis layer in ignite allows
> for this)
>
> 2. I am trying to build a ruby thin client for Apache Ignite and got a
> basic
> prototype in place. But I couldn't find an operation in binary protocol
> documentation that will enable us to set TTL for a key-value pair.  So, any
> idea on how to set TTL via the binary protocol?
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>