UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'knS0aqVaJVGdEhDRyaAqyIrkhRnlC2w6Ake08JpOzGs=' 
WHERE 
  key_id = 'c5e8086a8ac968d5432d664173adb10c97c714da21a70cc462530296d5becfee' 
  AND (
    token = 'knS0aqVaJVGdEhDRyaAqyIrkhRnlC2w6Ake08JpOzGs=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00047