lib/aerospike/client.rb
def truncate(namespace, set_name = nil, before_last_update = nil, options = {})
      policy = create_policy(options, Policy, default_info_policy)

      str_cmd = "truncate:namespace=#{namespace}"
      str_cmd << ";set=#{set_name}" unless set_name.to_s.strip.empty?

      if before_last_update
        lut_nanos = (before_last_update.to_f * 1_000_000_000.0).round
        str_cmd << ";lut=#{lut_nanos}"
      elsif supports_feature?(Aerospike::Features::LUT_NOW)
        # Servers >= 4.3.1.4 require lut argument
        str_cmd << ";lut=now"
      end

      # Send index command to one node. That node will distribute the command to other nodes.
      response = send_info_command(policy, str_cmd).upcase
      return if response == 'OK'
      raise Aerospike::Exceptions::Aerospike.new(Aerospike::ResultCode::SERVER_ERROR, "Truncate failed: #{response}")
    end
def truncate(namespace, set_name = nil, before_last_update = nil, options = {})
      policy = create_policy(options, Policy, default_info_policy)

      str_cmd = "truncate:namespace=#{namespace}"
      str_cmd << ";set=#{set_name}" unless set_name.to_s.strip.empty?

      if before_last_update
        lut_nanos = (before_last_update.to_f * 1_000_000_000.0).round
        str_cmd << ";lut=#{lut_nanos}"
      elsif supports_feature?(Aerospike::Features::LUT_NOW)
        # Servers >= 4.3.1.4 require lut argument
        str_cmd << ";lut=now"
      end

      # Send index command to one node. That node will distribute the command to other nodes.
      response = send_info_command(policy, str_cmd).upcase
      return if response == 'OK'
      raise Aerospike::Exceptions::Aerospike.new(Aerospike::ResultCode::SERVER_ERROR, "Truncate failed: #{response}")
    end
Removes records in the specified namespace/set efficiently.

 This method is orders of magnitude faster than deleting records one at a
 time. It requires Aerospike Server version 3.12 or later. See
 https://www.aerospike.com/docs/reference/info#truncate for further
 information.

 This asynchronous server call may return before the truncate is complete.
 The user can still write new records after the server call returns
 because new records will have last update times greater than the truncate
 cut-off (set at the time of the truncate call.)

 If no policy options are provided, +@default_info_policy+ will be used.