registerKeyForActiveExpiration registers a key with TTL in the timing wheel for active expiration.
(record *core.Record, entry *core.Entry)
| 841 | |
| 842 | // registerKeyForActiveExpiration registers a key with TTL in the timing wheel for active expiration. |
| 843 | func (db *DB) registerKeyForActiveExpiration(record *core.Record, entry *core.Entry) { |
| 844 | if db.ttlService == nil { |
| 845 | return |
| 846 | } |
| 847 | |
| 848 | meta := entry.Meta |
| 849 | |
| 850 | if meta.TTL > 0 && meta.Flag != DataDeleteFlag { |
| 851 | if db.ttlService.IsExpired(record.TTL, record.Timestamp) { |
| 852 | return |
| 853 | } |
| 854 | |
| 855 | // Deregister old TTL before registering new one (handles TTL updates) |
| 856 | db.ttlService.DeregisterKeyFromActiveExpiration(meta.BucketId, entry.Key) |
| 857 | |
| 858 | db.ttlService.RegisterKeyForActiveExpiration( |
| 859 | meta.BucketId, |
| 860 | entry.Key, |
| 861 | meta.Ds, |
| 862 | meta.TTL, |
| 863 | meta.Timestamp, |
| 864 | ) |
| 865 | } |
| 866 | } |
| 867 | |
| 868 | // buildSetIdx builds set index when opening the DB. |
| 869 | func (db *DB) buildSetIdx(record *core.Record, entry *core.Entry) error { |
no test coverage detected