You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/cqlengine/queryset.rst
+36Lines changed: 36 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -343,6 +343,42 @@ None means no timeout.
343
343
Setting the timeout on the model is meaningless and will raise an AssertionError.
344
344
345
345
346
+
.. _ttl-change:
347
+
348
+
Default TTL and Per Query TTL
349
+
=============================
350
+
351
+
Model default TTL now relies on the *default_time_to_live* feature, introduced in Cassandra 2.0. It is not handled anymore in the CQLEngine Model (cassandra-driver >=3.6). You can set the default TTL of a table like this:
352
+
353
+
Example:
354
+
355
+
.. code-block:: python
356
+
357
+
classUser(Model):
358
+
__options__ = {'default_time_to_live': 20}
359
+
360
+
user_id = columns.UUID(primary_key=True)
361
+
...
362
+
363
+
You can set TTL per-query if needed. Here are a some examples:
364
+
365
+
Example:
366
+
367
+
.. code-block:: python
368
+
369
+
classUser(Model):
370
+
__options__ = {'default_time_to_live': 20}
371
+
372
+
user_id = columns.UUID(primary_key=True)
373
+
...
374
+
375
+
user = User.objects.create(user_id=1) # Default TTL 20 will be set automatically on the server
376
+
377
+
user.ttl(30).update(age=21) # Update the TTL to 30
0 commit comments