Class TimeToLiveAttribute
Marks the property whose attribute is the time to live of the table: DynamoDB deletes an item some time after the instant it holds. CreateTable() of the entity turns time to live on for it, as
.TimeToLive(handle) on the chain does, and so does FakeDynamoDb.CreateTable<T> of DynaSharp.Testing.
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = false)]
public sealed class TimeToLiveAttribute : Attribute
- Inheritance
-
TimeToLiveAttribute
- Inherited Members
Remarks
DynamoDB reads a number of seconds since 1970-01-01T00:00:00Z and ignores an item whose attribute holds anything else, a string among them, so the property has to be stored as one: a DateTimeOffset with
[DynamoDbConverter(typeof(EpochSecondsConverter))], an integer that holds the seconds, or a converter of the application that is an IAddableConverter, which says that it writes a
number. Anything else is the error DYNA036, as is a second such property on one entity and one that is not stored, because a table has time to live on one attribute. Nullable is fine: an item
without the attribute never expires.
A table has one attribute of time to live, so CreateTable().Including<TOther>() throws ArgumentException for two entities that name different ones, as it does for other disagreements, and
an entity without one takes that of the others. .TimeToLive(...) on the chain replaces what the entities declare. Turning time to live on needs an active table, so the create waits for it, five minutes at most
unless WaitUntilActive(timeout) says otherwise, and takes dynamodb:DescribeTimeToLive and dynamodb:UpdateTimeToLive, also on a table that IfNotExists() finds: see
TimeToLive(string).
DynamoDB deletes within days of the expiry, not at it, and a read returns an expired item until then, so a read that must not see one filters on the attribute. It is on a property of an entity, not of a document.
Constructors
TimeToLiveAttribute()
public TimeToLiveAttribute()