package com.twitter.finagle.memcached.protocol

import com.twitter.logging.Logger
import com.twitter.util.Time

private[memcached] object ExpiryValidation {
  private val log = Logger.get()

  /**
   * Checks if expiry is valid
   */
  def checkExpiry(command: String, expiry: Time): Boolean = {
    // Item never expires if expiry is Time.epoch
    if (expiry == Time.epoch) true
    else if (expiry < Time.now) {
      log.warning(s"Negative expiry for $command: item will expire immediately")
      false
    } else true
  }
}

package com.twitter.finagle.memcached.protocol

import com.twitter.logging.{Level, Logger}
import com.twitter.util.Time

private[memcached] object ExpiryValidation {
  private val log = Logger.get()

  /**
   * Checks if expiry is valid
   */
  def checkExpiry(command: String, expiry: Time): Boolean = {
    // Item never expires if expiry is Time.epoch
    if (expiry == Time.epoch) true
    else if (expiry < Time.now) {
      if (log.isLoggable(Level.TRACE))
        log.trace(s"Negative expiry for $command: item will expire immediately")
      false
    } else true
  }
}

Change Expiry Logging Level to Trace
finagle-memcached: Change Expiry Logging Level to Trace

Problem

If a service is sending a command with a negative expiry, there's a
good chance that they're doing so many many times over. Therefore, a log
level of 'warning' is too heavyweight for a production service.

Solution

Turn the log level down to 'trace' so that if a service is setting a
negative expiry, they aren't impacted in production, but do have the
ability to track down where the offending call is coming from.

JIRA Issues: CSL-9665

Differential Revision: https://phabricator.twitter.biz/D521834
