UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'ffyRkDK+UQ5Ph2yTZpOifZE/PnJAFmVss99oRq/PzUg=' 
WHERE 
  key_id = '3096cd33505a09eb2c74301045c603784603070486b39c6b6b5dd9a8c8aede3e' 
  AND (
    token = 'ffyRkDK+UQ5Ph2yTZpOifZE/PnJAFmVss99oRq/PzUg=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00026