Skip to content

Latest commit

 

History

History
62 lines (44 loc) · 2.08 KB

BP_4012_en.md

File metadata and controls

62 lines (44 loc) · 2.08 KB

Set up a data expiration and deletion policy.

Identifiers

GreenIT V2 V3 V4

Categories

Life cycle Tiers Responsible
4. Production Datacenter System Administrator

Indications

Priority Implementation difficulty Ecological impact
4 3 4
Saved resources
Storage / Queries

Description

Following the General Data Protection Regulation (GDPR), it is mandatory to delete users personal data after a defined period. Lifespans can also be defined for data other than users personal data. Fortunately, setting up data lifespan can be done automatically without having to manually purge obsolete data.

Many database management systems, such as MongoDB, AWS DynamoDB, Redis, or Oracle, allow you to define a "TTL" (Time To Live) on a table or a, item. After defining a lifespan, expired data will be purged and permanently erased from database.

Example

In this Java example on an Oracle database, the data expires after 5 days.

String aKey = "myFirstKey";
String aData = "myFirstData";

try {
    DatabaseEntry theKey = new DatabaseEntry(aKey.getBytes("UTF-8"));
    DatabaseEntry theData = new DatabaseEntry(aData.getBytes("UTF-8"));

    WriteOptions wo = new WriteOptions();
    wo.setTTL(5); // TTL from 5 days
    myDatabase.put(null,             // Transaction
                   theKey,           // Key.
                   theData,          // value.
                   Put.NO_OVERWRITE,
                   wo);              // Options (including TTL duration).

} catch (Exception e) {
    // ...
}

Validation rule

The quantity of ... is equal to or less than
Unused stored data without any legal constraints 0