Count Expired
Counts the number of expired keys in the database.
- Parameters:
pattern
: Optional SQL LIKE pattern to match keys. Defaults to "%" which matches all keys.
- Returns:
- The result of the operation, includes the number of expired keys in the database or an error if the operation failed.
// Get the total number of expired keys with result type handling
const result = db.countExpired();
if (result.success) {
console.log(`Total expired keys: ${result.data}`);
} else {
console.log(result.error.message);
}
// Get the number of expired keys matching "user:%"
const userCountExpired = db.countExpired("user:%");