Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cassandra/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Cassandra 在列级别应用TTL_Cassandra_Ttl - Fatal编程技术网

Cassandra 在列级别应用TTL

Cassandra 在列级别应用TTL,cassandra,ttl,Cassandra,Ttl,想知道如何在列级应用TTL 下面的查询在记录级别设置TTL INSERT INTO excelsior.clicks ( userid, url, date, name) VALUES ( 3715e600-2eb0-11e2-81c1-0800200c9a66, 'http://apache.org', '2013-10-09', 'Mary' ) USING TTL 86400; 而我的要求是为特定列设置TTL。有没有办法实现这一

想知道如何在列级应用
TTL

下面的查询在记录级别设置
TTL

  INSERT INTO excelsior.clicks (
  userid, url, date, name)
  VALUES 
    (
    3715e600-2eb0-11e2-81c1-0800200c9a66,
   'http://apache.org',
   '2013-10-09', 'Mary'
     )
    USING TTL 86400;

而我的要求是为特定列设置
TTL
。有没有办法实现这一点

您可以使用部分数据执行
插入

cqlsh> create KEYSPACE test WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};
cqlsh> use test;
cqlsh:test> create table test(userid uuid, url text, date text, name text, primary key(userid));
cqlsh:test> 
cqlsh:test> insert into test(userid, url, date, name) VALUES 
        ...     (
        ...     3715e600-2eb0-11e2-81c1-0800200c9a66,
        ...    'http://apache.org',
        ...    '2013-10-09', 'Mary'
        ...      )
        ...     USING TTL 86400;
cqlsh:test> 
cqlsh:test> select userid, url, TTL(url), date, TTL(date), name, TTL(name) from test;

 userid                               | url               | ttl(url) | date       | ttl(date) | name | ttl(name)
--------------------------------------+-------------------+----------+------------+-----------+------+-----------
 3715e600-2eb0-11e2-81c1-0800200c9a66 | http://apache.org |    86342 | 2013-10-09 |     86342 | Mary |     86342

(1 rows)    
cqlsh:test> insert into test(userid, url ) VALUES (3715e600-2eb0-11e2-81c1-0800200c9a66,    'http://apache.org'   ) USING TTL 864000; 
cqlsh:test> 
cqlsh:test> select userid, url, TTL(url), date, TTL(date), name, TTL(name) from test;

 userid                               | url               | ttl(url) | date       | ttl(date) | name | ttl(name)
--------------------------------------+-------------------+----------+------------+-----------+------+-----------
 3715e600-2eb0-11e2-81c1-0800200c9a66 | http://apache.org |   863992 | 2013-10-09 |     86109 | Mary |     86109

(1 rows)
cqlsh:test> 
如果对每列执行insert语句,则可以分别为每列设置TTL