basho / riak-php-client

PHP clients for Riak
Apache License 2.0
160 stars 69 forks source link

How delete keys from some parameters ? [JIRA: CLIENTS-684] #112

Closed Ducatel closed 8 years ago

Ducatel commented 8 years ago

Hi everybody,

I'm trying to find a way to delete a set of keys.

I store data with this format:

$dataToStore = [
            "date" => time(),
            "data" => $myData
        ];

I didn't find how I can delete keys with condition like date < $anotherTimestamp. Is it possible ?

Can you help me on this point ? Thanks for your help ;)

christophermancini commented 8 years ago

Hi @Ducatel, currently there is not a way to automatically delete keys from within Riak KV out of the box at this time. You would have to develop a background / cron process to determine which keys are "expired" then manually delete them.

One way you could do this is with Yokozuna (Solr), which allows you to set search indexes for a bucket type to index your "date" field, then do Solr range lookups on that index. Then delete each key found to match that lookup.

As part of our development of Riak TS (Time Series), we will be adding support for data to expire efficiently as an out of the box feature. Unfortunately, I do not have a timeline for that development.

Also, there is possibility you can configure expiration of keys directly in the backend storage engine (bitcask, leveldb, etc) you are using, but it is not backend agnostic or configurable within Riak. Which would require knowledge of your chosen backend and what behaviors that could introduce with your use of Riak.

Ducatel commented 8 years ago

Ok, so I will use Yokozuna to do it ;) http://docs.basho.com/riak/latest/dev/using/search/

Thanks for your help.

christophermancini commented 8 years ago

Your quite welcome! :)